Skip to content

Instantly share code, notes, and snippets.

@fdietz
Created February 19, 2013 19:18
Show Gist options
  • Save fdietz/4988944 to your computer and use it in GitHub Desktop.
Save fdietz/4988944 to your computer and use it in GitHub Desktop.
Recipes with Angular.js: Controllers - Encapsulating a Model Value with a Controller Function
function MyCtrl($scope) {
$scope.value = 1;
$scope.getIncrementedValue = function() {
return $scope.value + 1;
};
}
<html>
<head>
<script src="js/angular.js"></script>
<script src="js/app.js"></script>
<link rel="stylesheet" href="css/bootstrap.css">
</head>
<body ng-app>
<div ng-controller="MyCtrl">
<p>{{getIncrementedValue()}}</p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment