- ng-model
- ng-click
Angular controller with binding
examples/angular/hello_user_controller.html
<script src="angular.min.js"></script> <script src="hello_user_controller.js"></script> <div ng-app="HelloUserApp"> <div ng-controller="HelloUserController"> <input ng-model="name"><button ng-click="NameChange()">Update</button> <h1>greeting: {{greeting}}</h1> <h2>name: {{name}}</h2> </div> </div>
examples/angular/hello_user_controller.js
angular.module('HelloUserApp', []) .controller('HelloUserController', ['$scope', function($scope) { $scope.NameChange = function () { $scope.greeting = "Hello " + $scope.name; }; }]);