【发布时间】:2017-02-20 06:54:49
【问题描述】:
今天早上醒来发现我的应用程序不再工作了。它使用的组件框架类似于 Angular-ui-router 教程 Hello Galaxy (https://ui-router.github.io/tutorial/ng1/hellogalaxy) 中使用的组件框架,但截至今天早上也无法使用。
这样的状态:
var states = [
{ name: 'hello', url: '/hello', component: 'hello' },
{ name: 'about', url: '/about', component: 'about' }]
然后注册状态。
这样的组件:
angular.module('app').component('hello', {
template: '<h3>{{$ctrl.greeting}} galaxy!</h3>' +
'<button ng-click="$ctrl.toggleGreeting()">toggle greeting</button>',
controller: function() {
this.greeting = 'hello';
this.toggleGreeting = function() {
this.greeting = (this.greeting == 'hello') ? 'whats up' : 'hello'
}
}
})
我正在使用 Angular 1.58 和最新的 ui-router。
错误信息是: 未捕获的类型错误:angular.module(...).component 不是函数(匿名函数)@ hello.js:1 about.js:1 Uncaught TypeError: angular.module(...).component is not a function(anonymous function) @ about.js:1, etc.
昨晚我的应用和 ui-router 的应用都运行良好。
【问题讨论】:
-
好像没有加载 angular.js?
-
我认为角度版本已被意外覆盖。检查安装的版本(如果使用凉亭。使用
bower info angular) -
也许您之前没有定义模块...尝试使用以下代码开始您的代码:angular.module('app', [])
标签: angularjs angular-ui-router