Skip to content

Instantly share code, notes, and snippets.

@aledwassell
Created March 2, 2017 12:12
Show Gist options
  • Save aledwassell/23e271de312992bfe53ecae0a7039272 to your computer and use it in GitHub Desktop.
Save aledwassell/23e271de312992bfe53ecae0a7039272 to your computer and use it in GitHub Desktop.
playing around with angular JS
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