angularjs - No NgModule in folders generated by Angular-Cli -
i newbie angular.js. have learn angular.js's basic notions , understand project structure.
but when use angular-cli generate basic project, find in project there no ngmodule in root src folder. accord docs in homepage of angular, root ngmodule. here question, difference between them. , why angular-cli use component root? thanks.
i think angular-cli has not been updated yet. angular 2 still changing fast.
but, can create yourself:
$ ng new yourproject
then navigate inside yourproject/src/
folder, replace main.ts
way:
import { platformbrowserdynamic } '@angular/platform-browser-dynamic'; import { appmodule } './app/app.module'; platformbrowserdynamic().bootstrapmodule(appmodule);
now go yourproject/src/app
folder , create app.module.ts
:
import { ngmodule } '@angular/core'; import { browsermodule } '@angular/platform-browser'; import { mdbuttonmodule } '@angular2-material/button'; import { appcomponent } './app.component'; @ngmodule({ imports: [ browsermodule ], declarations: [ appcomponent ], bootstrap: [ appcomponent ] }) export class appmodule { }
you may need add/update dependecies in yourproject/package.json
. here mine:
"dependencies": { "@angular/common": "2.0.0-rc.5", "@angular/compiler": "2.0.0-rc.5", "@angular/core": "2.0.0-rc.5", "@angular/forms": "0.3.0", "@angular/http": "2.0.0-rc.5", "@angular/platform-browser": "2.0.0-rc.5", "@angular/platform-browser-dynamic": "2.0.0-rc.5", "@angular/router": "3.0.0-rc.1", "@angular/router-deprecated": "2.0.0-rc.2", "@angular/upgrade": "2.0.0-rc.5", "bootstrap": "^3.3.6", "core-js": "^2.4.0", "es6-shim": "0.35.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.6", "systemjs": "0.19.27", "zone.js": "^0.6.12" }, "devdependencies": { "angular-cli": "1.0.0-beta.10", "codelyzer": "0.0.20", "ember-cli-inject-live-reload": "1.4.0", "jasmine-core": "2.4.1", "jasmine-spec-reporter": "2.5.0", "karma": "0.13.22", "karma-chrome-launcher": "0.2.3", "karma-jasmine": "0.3.8", "protractor": "3.3.0", "ts-node": "0.5.5", "tslint": "^3.7.4", "typescript": "^1.8.10", "typings": "1.3.1" }
Comments
Post a Comment