Skip to content

Instantly share code, notes, and snippets.

@mduleone
Created March 16, 2014 15:58
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 mduleone/9585345 to your computer and use it in GitHub Desktop.
Save mduleone/9585345 to your computer and use it in GitHub Desktop.
//function MyCtrl($scope){
// $scope.clock = {
// now: new Date()
// };
// var updateClock = function() {
// $scope.clock.now = new Date();
// };
// setInterval(function(){ $scope.$apply(updateClock);}, 1000);
// updateClock();
//};
angular.module('emailParser', [])
.config(['$interpolateProvider', function($interpolateProvider){
$interpolateProvider.startSymbol('__');
$interpolateProvider.endSymbol('__');
}])
.factory('EmailParser', ['$interpolate', function($interpolate){
return {
parse : function(text, context){
var template = $interpolate(text);
return template(context);
}
}
}]);
angular.module('myApp.filters', [])
.filter('capitalize', function(){
return function(input){
if(input){
return input[0].toUpperCase() + input.slice(1);
}
}
});
app = angular.module('myApp', ['emailParser', 'myApp.filters']);
app.run(function($rootScope){
$rootScope.name = "world";
});
//angular.module('myApp', [])
app.controller('myController',
function($scope){
$scope.name = 'Matt';
});
//angular.module('myApp', [])
app.controller('FirstController', function($scope){
$scope.counter = 0;
$scope.add = function(amount){$scope.counter += amount;};
$scope.subtract = function(amount){$scope.counter -= amount;};
});
app.controller('ParentController', function($scope){
$scope.person = {greeted: false};
});
app.controller('ChildController', function($scope){
$scope.sayHello = function(){
$scope.person.name = 'Matt DuLeone';
$scope.person.greeted = true;
};
});
app.controller('MyController', function($scope, $parse){
$scope.$watch('expr', function(newVal, oldVal, scope){
if(newVal != oldVal){
var parseFun = $parse(newVal);
$scope.parsedValue = parseFun(scope);
}
});
});
//app.controller('newController', function($scope, $interpolate){
// $scope.$watch('emailBody', function(body){
// if(body){
// var template = $interpolate(body);
// $scope.previewText = template({to: $scope.to});
// }
// });
//});
app.controller('newController', ['$scope', 'EmailParser', function($scope, EmailParser){
$scope.$watch('emailBody', function(body){
if(body){
$scope.previewText = EmailParser.parse(body, {to: $scope.to});
}
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment