Skip to content

Instantly share code, notes, and snippets.

@podhmo
Created January 23, 2016 15:09
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 podhmo/200da13416a7ed5fa673 to your computer and use it in GitHub Desktop.
Save podhmo/200da13416a7ed5fa673 to your computer and use it in GitHub Desktop.
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