Last active
August 29, 2015 14:17
-
-
Save kalbarczyk/86ebc0c1d49cef28dd23 to your computer and use it in GitHub Desktop.
AngularJS - $scope vs. scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml" data-ng-app="app"> | |
<head> | |
<meta charset="utf-8"> | |
<title>AngularJS - $scope vs. scope</title> | |
</head> | |
<body ng-controller="defaultCtrl"> | |
<h3>$scope vs. scope</h3> | |
<div test-scope></div> | |
<div test-scope2></div> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script> | |
<script> | |
(function () { | |
'use strict'; | |
angular | |
.module('app', []); | |
})(); | |
(function () { | |
'use strict'; | |
angular | |
.module('app') | |
.controller('defaultCtrl', defaultCtrl); | |
defaultCtrl.$inject = ['$scope']; | |
function defaultCtrl($scope) { | |
console.log('Controller=', $scope); | |
} | |
})(); | |
(function () { | |
'use strict'; | |
angular | |
.module('app') | |
.directive('testScope', testScope); | |
function testScope() { | |
return { | |
link: function (scope) { | |
console.log('testScope=', scope); | |
} | |
}; | |
} | |
})(); | |
(function () { | |
'use strict'; | |
angular | |
.module('app') | |
.directive('testScope', testScope); | |
function testScope() { | |
return { | |
scope: {}, | |
link: function (scope) { | |
console.log('testScope2=', scope); | |
} | |
}; | |
} | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment