2
votes

I just can't figure it out why my html is not working. I have just clone the angular-seed from the github and trying to make some changes to learn more about angular.

view2.js

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

i have just added a single line of code $scope.message and i have call the message in 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>

I am getting the error

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)

I think i am missing something.

1
Have you minified the code?Tushar
sorry i didn't get you minified means??gaurav tiwari
have you included all the js files in index.html?DarkMakukudo
yess everything is same i have not touched the index.html file of angular seedgaurav tiwari
how did you map that this view should belong to this controller? did you use ng-controller? or you just configured it in route params? Please add complete codeDarkMakukudo

1 Answers

3
votes

If you it is minified code then make this change before minification

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

}]);