我只是无法弄清楚为什么我的HTML无法正常工作。我刚刚从github克隆了有角度的种子,并尝试进行一些更改以了解有关有角度的更多信息。
view2.js
.controller('View2Ctrl', [function($scope) {
$scope.message='hello every one';
}]);
我刚刚添加了一行代码$ scope.message,并在其中调用了该消息 view2.html
view2.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://本地主机:8000 /应用程序/视图2 / view2.js:13:15)中的调用(HTTP://本地主机:8000 /应用程序/ bower_components /角度/ angular.js:4560:17)在Object.instantiate(HTTP://本地主机:8000 /应用程序/ bower_components /角度/ angular.js:4568:27)在HTTP://本地主机:8000 /应用程序/ bower_components /角度/ angular.js:9440:28在链路(HTTP://本地主机:8000 /应用程序/ bower_components /角路线/角route.js:985:26)在invokeLinkFn(HTTP://本地主机:8000 /应用程序/ bower_components /linkular/angular.js:9079:9)在CompositeLinkFn(http:// localhost:8000 / app / bower_components / angular / angular.js:8566:11)位于publicLinkFn的http:// localhost:8000 / app / bower_components / angular / angular.js:7965:13)(http:// localhost:8000 / app / bower_components / angular / angular.js:7845:30)位于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';
}]);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句