不能设置未定义的属性
Can not set property of undefined
我只是想不通为什么我的html不起作用。我刚刚从github克隆了角度种子,并尝试进行一些更改以了解有关角度的更多信息。
视图2.js
.controller('View2Ctrl', [function($scope) {
$scope.message='hello every one';
}]);
我刚刚$scope.message中添加了一行代码,并且我用view2.html
调用了该消息
视图2.html
<p>This is the partial for view 2.</p>
<h1>hello</h1>
<p>{{message}}</p>
<p>
Showing of 'interpolate' filter:
{{ 'Current version is v%VERSION%.' | interpolate }}
</p>
我收到错误
类型错误: 无法设置未定义的属性"消息" 在新 (http://localhost:8000/app/view2/view2.js:13:15) 调用时 (http://localhost:8000/app/bower_components/angular/angular.js:4560:17) at Object.instanceiate (http://localhost:8000/app/bower_components/angular/angular.js:4568:27) 在 http://localhost:8000/app/bower_components/angular/angular.js:9440:28 在链接 (http://localhost:8000/app/bower_components/angular-route/angular-route.js:985:26) at invokeLinkFn (http://localhost:8000/app/bower_components/angular/angular.js:9079:9) at nodeLinkFn (http://localhost:8000/app/bower_components/angular/angular.js:8566:11) at compositeLinkFn (http://localhost:8000/app/bower_components/angular/angular.js:7965:13) at publicLinkFn (http://localhost:8000/app/bower_components/angular/angular.js:7845:30) at boundTranscludeFn (http://localhost:8000/app/bower_components/angular/angular.js:7983:16)
我想我错过了一些东西。
如果你是缩小的代码,那么在缩小之前进行此更改
.controller('View2Ctrl', ['$scope',function($scope) { // note $scope added
$scope.message='hello every one';
}]);
- 主干中的模型属性未定义
- JavaScript 2d 数组导致“无法读取未定义的属性'未定义'”
- JSON对象属性未定义
- Waypoint的循环,退出循环后属性未定义
- Javascript:错误“无法设置属性”..'未定义”
- 翡翠 - 显示对象属性 - 未定义
- 属性未定义,但控制台.log可以看到它
- JavaScript 对象的属性未定义
- Javascript 对象属性未定义(但属性已设置)
- DOM 元素属性未定义 - jquery / ruby on rails.
- Nodejs JSON 属性未定义
- 错误:窗口打开器的属性未定义
- angular Js:Array.lenght属性未定义
- 正在尝试访问JavaScript对象的属性=未定义
- Marionette属性未定义,请从API获取
- AngularJS作用域属性未定义
- 对象的属性未定义,尽管已指定值
- 为什么我一直收到一个错误,说对象属性未定义
- 对象属性未定义,但我看到它不是
- .map()img src属性未定义