I'm new to AngularJs and I try to understand the basics of controller binding. lets say I have this in my html page:
<div ng-controller ="MainController">
<h2>{{message}}</h2>
</div>
Now, in my script file I have two options(as I saw in different tutorials):
1:
var myApp = angular.module('myApp',[]);
myApp.controller('MainController', ['$scope', function($scope) {
$scope.message = 'hello';
}]);
2:
var MainController = function($scope)
{
@scope.message = "Hello";
};
Offcourse I prefer the second approach however only the first option works for me. I'm working with AngularJS 1.4.4, could it be the second approach is now deprecated?
Thanks!