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
$scope = null; // $scope object will be garbage collected, but nothing else |
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
$scope.$parent = $scope.$$nextSibling = $scope.$$prevSibling = $scope.$$childHead = | |
$scope.$$childTail = $scope.$root = $scope.$$watchers = null; |
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
angular.module('myModule').controller('fileUploadCtrl', function($scope, FileUploader){ | |
$scope.uploader = new FileUploader({ | |
settings: {} | |
}); | |
var reader = new FileReader(); | |
reader.onload = function(event) { | |
var img = new Image(); |
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
scope.tree = { | |
type: 'oak', | |
branches: [{ | |
color: 'brown', | |
length: '11', | |
leaves: [{ | |
color: 'green', | |
shape: 'oval', | |
}, { | |
color: 'brown', |
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
scope.greeting = 'hi there'; | |
scope.$watch('greeting', function(greeting) { | |
console.log('greeting: ', greeting); // greeting: hi there | |
}); |
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 fullName = 'last + ", " + first'; | |
var getFullName = $parse(fullName); // getFullName is the parseFn! | |
var context = {first: 'steph', last: 'curry'}; | |
getFullName(context); // => curry, steph | |
context = {first: 'russ', last: 'westbrook'}; | |
getFullName(context); // => westbrook, russ |
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
scope.$watch('greeting', function(greeting) { | |
console.log('greeting: ', greeting); | |
}); | |
scope.greeting = 'hi there'; // greeting: hi there | |
$timeout(function() { scope.greeting += ', Joe'}); // greeting: hi there, Joe |
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
$scope.firstTeam = [{ | |
first: 'steph', | |
last: 'curry' | |
}, { | |
first: 'lebron', | |
last: 'james' | |
}]; | |
$scope.$watchCollection('firstTeam', function(firstTeamArray) { | |
console.log("change to the first team! ", JSON.stringify(firstTeamArray)); | |
}); |
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 context = {first: 'steph', last: 'curry'}; | |
// with string | |
var string = 'last + ", " + first'; | |
var parseFn = $parse(string); | |
parseFn(context); // => curry, steph | |
// with function | |
var func = function(context) { | |
return context.last + ', ' + context.first; |
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
scope.$watch('obj1', function callback(newValue) { | |
console.log('obj1: ', newValue); | |
}); | |
// (when initialized) prints out: undefined | |
$timeout(function() { | |
scope.obj1 = {name: 'jonathan'}; // prints out: {name: 'jonathan'} | |
}); |