formations/javascript/angular/directives-2.md

30 lines
657 B
Markdown
Raw Permalink Normal View History

2015-04-09 20:36:17 +02:00
# .cadoles-slide-title[Les directives de base (2/5)]
2015-04-08 23:22:53 +02:00
**Itération avec ng-repeat: sur un objet**
```html
<html>
<body ng-app="myApp">
<div ng-controller="MainCtrl">
<ul>
<li ng-repeat="(key, val) in myObj">
<span>Clé: {{ key }}</span><span>Valeur: {{ value }}</span>
</li>
</ul>
</div>
<script src="angular.js"></script>
<script>
angular.module('myApp', [])
.controller('MainCtrl', ['$scope', function($scope) {
$scope.myObj = [
'prop1': 'Foo',
'prop2': 'Bar'
'prop3': 'Baz'
];
}]);
</script>
</body>
</html>
```