Created
March 2, 2017 12:12
-
-
Save aledwassell/23e271de312992bfe53ecae0a7039272 to your computer and use it in GitHub Desktop.
playing around with angular JS
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 myApp = angular.module('myApp', []); | |
myApp.controller('mainController', ['$scope', '$filter', function($scope, $filter) { | |
$scope.handle = ""; | |
$scope.lowerCaseFilter = function() { | |
return $filter('lowercase')($scope.handle); | |
}; | |
$scope.$watch('handle', function(newValue, oldValue) { | |
console.info("changed"); | |
console.log("old: " + oldValue); | |
console.log("new: " + newValue); | |
}); | |
//$apply helpes angular see other code that lives outside the angular context | |
setTimeout(function() { //setTimeoutbeing a javascript native code, this could be jquery etc... | |
$scope.$apply(function() { | |
$scope.handle = "Aled is cool" | |
console.log("done"); | |
}) | |
}, 4000); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment