Skip to content

Instantly share code, notes, and snippets.

@kalbarczyk
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalbarczyk/86ebc0c1d49cef28dd23 to your computer and use it in GitHub Desktop.
Save kalbarczyk/86ebc0c1d49cef28dd23 to your computer and use it in GitHub Desktop.
AngularJS - $scope vs. scope
<!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