Voulez créer un composant imbriqué dans angulaire 6. La structure du dossier est src-> app-> content-> 1.home, 2.product veut créer un composant dans le produit. je l'ai fait déjà dans le dossier produit c: / users / admin / project / test / src / app / content / product> ng g composant conseil sur cmd

Obtenir une erreur en tant que: jeton inattendu / dans JSON à la position 1122

3
vedika shrivas 23 mai 2018 à 13:40

3 réponses

Meilleure réponse

Source copiée à partir de la doc angular-cli officiel

ng generate component my-new-component
ng g component my-new-component  // using the alias

// components support relative path generation
// if in the directory src/app/feature/ and you run
ng g component new-cmp
// your component will be generated in src/app/feature/new-cmp
// but if you were to run
ng g component ./newer-cmp
// your component will be generated in src/app/newer-cmp
// if in the directory src/app you can also run

    ng g component feature/new-cmp

// and your component will be generated in src/app/feature/new-cmp
9
Anuradha Gunasekara 23 mai 2018 à 10:49

Allez dans le répertoire racine où se trouve angular-cli

Et donnez la commande comme suit

c :/users/admin/project/test/src/app/content > ng g c product/advisory
2
Padmapriya Vishnuvardhan 23 mai 2018 à 10:50
C:\depot\sandbox>ng g c outside
CREATE src/app/outside/outside.component.html (22 bytes)
CREATE src/app/outside/outside.component.spec.ts (635 bytes)
CREATE src/app/outside/outside.component.ts (274 bytes)
CREATE src/app/outside/outside.component.scss (0 bytes)
UPDATE src/app/app.module.ts (546 bytes)

C:\depot\sandbox>ng g c outside/inside
CREATE src/app/outside/inside/inside.component.html (21 bytes)
CREATE src/app/outside/inside/inside.component.spec.ts (628 bytes)
CREATE src/app/outside/inside/inside.component.ts (270 bytes)
CREATE src/app/outside/inside/inside.component.scss (0 bytes)
UPDATE src/app/app.module.ts (636 bytes)

C:\depot\sandbox>ng g c outside/inside-too
CREATE src/app/outside/inside-too/inside-too.component.html (25 bytes)
CREATE src/app/outside/inside-too/inside-too.component.spec.ts (650 bytes)
CREATE src/app/outside/inside-too/inside-too.component.ts (285 bytes)
CREATE src/app/outside/inside-too/inside-too.component.scss (0 bytes)
UPDATE src/app/app.module.ts (740 bytes)

Exemple de extrait de angular bug tracker sur github.

1
Frank Nocke 20 janv. 2020 à 15:37