<input ng-model='model1'/> Hello {{model1}}!
<div ng-controller='DataBindCtrl'> <input ng-model='model2'/> Hello {{model2}}! </div>
function DataBindCtrl($scope) { $scope.model2 = "World"; }
<div ng-controller="DirectiveTestCtrl"> <button ng-click="ajouteMessage()"> + </button> {{messageCount}} <div ng-show="messageCount > 3" ng-class="{alert: messageCount > 5}"> Il y a {{messageCount}} messages </div> </div>
function DirectiveTestCtrl($scope) { $scope.messageCount = 0 ; $scope.ajouteMessage = function(){ $scope.messageCount++; } }
<ul> <li ng-repeat="message in messageListe track by $index">{{message}}</li> </ul>
function DirectiveTestCtrl($scope) { $scope.messageListe = ["message1","message2"]; $scope.ajouteMessage = function(){ $scope.messageListe.push("message"+parseInt(Math.random()*10,10)); } }
<span my-directive=""></span>
<span class="my-directive: expression;"></span>
<my-directive></my-directive>
<!-- directive: my-directive expression -->
angular.module('myModule',[]) .value('myValue', 'Hello World') .controller('myController', function($scope, myValue) { $scope.value = myValue; });
angular.module('myModule',['ngResource']) .controller('myController', function($scope,$resource) { var User = $resource('/user/:userId', {userId:'@id'}); User.get({userId:123}, function(user) { user.abc = true; user.$save(); }); });