angular2教程例子配置文件

angular2教程例子配置文件

学习angular2官方文档的《路由与导航》一节时下载的例子缺少配置文件,npm start无法运行程序,在router目录下添加如下两个文件即可。

1. bs-config.json
{
  "server": {
    "baseDir": "src",
    "routes": {
      "/node_modules": "node_modules"
    }
  }
}
2. typings.json
{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160725163759",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "node": "registry:dt/node#6.0.0+20160909174046"
  }
}

添加完毕后文件目录结构应该是下面这样:

C:.
│  bs-config.json
│  package.json
│  typings.json
│  
└─src
    │  index.html
    │  main.ts
    │  systemjs-angular-loader.js
    │  systemjs.config.js
    │  tsconfig.json
    │  
    └─app
        │  animations.ts
        │  app-routing.module.ts
        │  app.component.ts
        │  app.module.ts
        │  auth-guard.service.ts
        │  auth.service.ts
        │  can-deactivate-guard.service.ts
        │  compose-message.component.html
        │  compose-message.component.ts
        │  dialog.service.ts
        │  login-routing.module.ts
        │  login.component.ts
        │  not-found.component.ts
        │  selective-preloading-strategy.ts
        │  
        ├─admin
        │      admin-dashboard.component.ts
        │      admin-routing.module.ts
        │      admin.component.ts
        │      admin.module.ts
        │      manage-crises.component.ts
        │      manage-heroes.component.ts
        │      
        ├─crisis-center
        │      crisis-center-home.component.ts
        │      crisis-center-routing.module.ts
        │      crisis-center.component.ts
        │      crisis-center.module.ts
        │      crisis-detail-resolver.service.ts
        │      crisis-detail.component.ts
        │      crisis-list.component.ts
        │      crisis.service.ts
        │      
        └─heroes
                hero-detail.component.ts
                hero-list.component.ts
                hero.service.ts
                heroes-routing.module.ts
                heroes.module.ts
3. npm install
4. npm start

若是npm start失败,还可能需要安装下面两个库:
npm install phantomjs-prebuilt@2.1.14
npm install @angular/animations@4.0.3
根据命令行提示缺少的库进行安装。
npm start 运行即可

5. 虽然工程可以运行,但是你发现样式似乎不对,在src目录下添加styles.css文件,内容从在线例子上拷贝下来即可。
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值