2016-12-14 93 views

回答

5

在您的角cli.json文件,如果你希望你的文件有內聯CSS和模板,你可以指定。

這樣,當您使用ng generate component時,它將使用默認值。

{ 
    "project": { 
     "version": "1.0.0-beta.22-1", 
     "name": "client" 
    }, 
    "apps": [ 
     { 
     "root": "src", 
     "outDir": "build", 
     "assets": [ 
      "assets", 
      "favicon.ico" 
     ], 
     "index": "index.html", 
     "main": "main.ts", 
     "test": "test.ts", 
     "tsconfig": "tsconfig.json", 
     "prefix": "ws", 
     "mobile": false, 
     "styles": [ 
      "styles/main.scss" 
     ], 
     "scripts": [], 
     "environments": { 
      "source": "environments/environment.ts", 
      "prod": "environments/environment.prod.ts", 
      "dev": "environments/environment.dev.ts" 
     } 
     } 
    ], 
    "addons": [], 
    "packages": [], 
    "e2e": { 
     "protractor": { 
     "config": "./protractor.conf.js" 
     } 
    }, 
    "test": { 
     "karma": { 
     "config": "./karma.conf.js" 
     } 
    }, 
    "defaults": { 
     "styleExt": "scss", 
     "prefixInterfaces": false, 
     "inline": { 
     "style": true, <<<--- CHECK IT OUT!! 
     "template": true 
     }, 
     "spec": { 
     "class": false, 
     "component": true, 
     "directive": true, 
     "module": false, 
     "pipe": true, 
     "service": true 
     } 
    } 
    }