Created
January 23, 2016 15:09
-
-
Save podhmo/200da13416a7ed5fa673 to your computer and use it in GitHub Desktop.
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
var ca = require('console-angular'); | |
ca.setup(function(angular){ | |
var injector = angular.injector(["ng"]); | |
var $rootScope = injector.get("$rootScope"); | |
var childScope = $rootScope.$new(); | |
var grandChildScope = childScope.$new(); | |
console.log(grandChildScope.$parent.$parent === $rootScope); | |
console.log("----------------------------------------"); | |
console.log("without as syntax"); | |
console.log("----------------------------------------"); | |
$rootScope.x = "xxxxx"; | |
console.log("root: %s", $rootScope.x); | |
console.log("root -> child: %s", childScope.x); | |
console.log("root -> child -> grand-child: %s", grandChildScope.x); | |
console.log("----------------------------------------"); | |
childScope.x = "yyyyy"; | |
console.log("root: %s", $rootScope.x); | |
console.log("root -> child: %s", childScope.x); | |
console.log("root -> child -> grand-child: %s", grandChildScope.x); | |
function Controller(){ | |
this.x = "xxxxx"; | |
} | |
$rootScope.c = new Controller(); | |
console.log("\n----------------------------------------"); | |
console.log("using as syntax"); | |
console.log("----------------------------------------"); | |
console.log("root: %s", $rootScope.c.x); | |
console.log("root -> child: %s", childScope.c.x); | |
console.log("root -> child -> grand-child: %s", grandChildScope.c.x); | |
// settings | |
childScope.c.x = "yyyyy"; | |
console.log("----------------------------------------"); | |
console.log("settings: childScope.c.x <- 'yyyyyy'"); | |
console.log("----------------------------------------"); | |
console.log("root: %s", $rootScope.c.x); | |
console.log("root -> child: %s", childScope.c.x); | |
console.log("root -> child -> grand-child: %s", grandChildScope.c.x); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment