typescript – VS angular2更改不会在浏览器上更新

前端之家收集整理的这篇文章主要介绍了typescript – VS angular2更改不会在浏览器上更新前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我开始使用Angular2,当我第一次尝试运行我的项目时,它可以工作.问题是我正在关注教程,当我运行它时,任何浏览器都没有显示任何更改!

这是我的“app.component.ts”:

  1. import {Component} from 'angular2/core';
  2.  
  3. @Component({
  4. selector: 'my-app',template: '<h1>Testing...</h1>'
  5. })
  6.  
  7. export class AppComponent {
  8. title = 'Tour of Heroes';
  9. }

这在任何浏览器上显示都可以,但是当我改为这个时:

  1. import {Component} from 'angular2/core';
  2.  
  3. @Component({
  4. selector: 'my-app',template: '<h1>{{title}}</h1>'
  5. })
  6.  
  7. export class AppComponent {
  8. title = 'Tour of Heroes';
  9. }

它继续显示“测试……”.它假设显示“英雄之旅”.为什么?

我的所有其他文件与教程相同!

Ps.:我已经安装了“node and npm”!

[@PankajParkar提到需要编辑“System.config”]
这就是我在index.html上的内容,与Angular2上的教程相同

  1. <script>
  2. System.config({
  3. packages: {
  4. app: {
  5. format: 'register',defaultExtension: 'js'
  6. }
  7. }
  8. });
  9. System.import('app/main').then(null,console.error.bind(console));
  10. </script>
这个问题令人沮丧,但这就是我的工作方式.

在浏览器中点击F12以显示开发人员工具.禁用缓存,如下所示

其次,我必须在web.config中的标记上方添加此部分以禁用缓存

  1. <location path="app">
  2. <system.webServer>
  3. <staticContent>
  4. <clientCache cacheControlMode="DisableCache"/>
  5. </staticContent>
  6. </system.webServer>
  7. </location>

猜你在找的Angularjs相关文章