I am playing around with different ways of loading an alert on load with angularJS. I saw this method documented:
JS
$scope.init = function () {
($window.mockWindow || $window).alert('Hello');
};
HTML
<div data-ng-controller="myCtrl" data-ng-init="init()">
<span id="logo">Just a</span><span id="small" >PREVIEW</span>
</div>
I get the following error:
Uncaught ReferenceError: $scope is not defined
Can anyone tell me what I am doing wrong with this implementation please?
$scope
only exists inside a controller, whereas your code isn't. In that case it's not so strange$scope
isn't defined. – 11684 Sep 15 '13 at 16:48