2016-03-23 27 views
2

私のhtmlがうまくいかない理由はわかりません。私はちょうどギブスの角種子をクローンし、角度についてもっと学ぶためにいくつかの変更を加えようとしています。未定義のプロパティを設定できません

view2.js

.controller('View2Ctrl', [function($scope) { 
    $scope.message='hello every one'; 
}]); 

私はちょうどコード$ scope.messageの単一の行を追加していると私は

<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> 
view2.html view2.html

にメッセージを呼び出しています

エラーが発生します

TypeError: Cannot set property 'message' of undefined at new (http://localhost:8000/app/view2/view2.js:13:15) at invoke (http://localhost:8000/app/bower_components/angular/angular.js:4560:17) at Object.instantiate (http://localhost:8000/app/bower_components/angular/angular.js:4568:27) at http://localhost:8000/app/bower_components/angular/angular.js:9440:28 at link (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)

私は何か不足していると思います。

+1

前にこの変更を行った後、コードを縮小されます場合は、あなたは、コードを縮小さがありますか? – Tushar

+0

申し訳ありません私はあなたが縮小された手段を得ることはありませんでしたか? –

+0

すべてのjsファイルをindex.htmlに含めましたか? – Sherlock

答えて

3

それが縮小

.controller('View2Ctrl', ['$scope',function($scope) { // note $scope added 
$scope.message='hello every one'; 

}]); 
+0

または、「.controller( 'View2Ctrl'、function($ scope){ $ scope.message = 'hello every ;; }); '、あなたがコードを小さくするつもりでないならば。 –

関連する問題