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
<input type="text" ng-model="modelName" nullify-model> |
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
.directive('nullifyModel', ['$filter', | |
function($filter){ | |
return { | |
restrict: 'A', | |
require: "ngModel", | |
link: link | |
}; | |
function link(scope, elem, attrs, ctrl){ | |
ctrl.$parsers.push($filter('nullify')); |
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
.filter('nullify', function(){ | |
return function(value){ | |
return value ? value : 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
<i class="icon upvote" ng-click="vm.user.upvote(vm.answer)"></i> |
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
<i class="icon upvote" | |
ng-click="vm.user.upvote(vm.answer)" | |
ng-class="{voted: vm.answer.isVotedFor(vm.user)}"> | |
</i> |
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
<i class="icon upvote" | |
ng-click="vm.user.upvote(vm.answer)" | |
ng-class="{voted: vm.answer.isVotedFor(vm.user)}"> | |
</i> | |
{{ vm.answer.voteCount() }} | |
<i class="icon downvote" | |
ng-click="vm.user.downvote(vm.answer)" | |
ng-class="{voted: vm.answer.isVotedAgainst(vm.user)}"> | |
</i> |
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.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.$watch('obj1', function callback(newValue) { | |
console.log('obj1: ', newValue); | |
}); | |
// (when initialized) prints out: undefined | |
$timeout(function() { | |
scope.obj1 = {name: 'jonathan'}; // prints out: {name: 'jonathan'} | |
}); |
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.$watchGroup(['expression1', 'expression2'], function(arrayOfExpressions) { | |
... | |
}); |
OlderNewer