-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntegrationExample.js
More file actions
50 lines (50 loc) · 1.54 KB
/
Copy pathIntegrationExample.js
File metadata and controls
50 lines (50 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
angular.module('integration-example', [])
.run(function($templateCache) {
var primitivesForm = '<input ng-model="itm">';
$templateCache.put('primitives.form', primitivesForm);
var objectsForm = '<input ng-model="itm.val">';
$templateCache.put('objects.form', objectsForm);
})
.controller('MainCtrl', function($scope) {
$scope.name = 'MainCtrl';
$scope.items = [{'val' : 'A'}, {'val' : 'B'}, {'val': 'C'}];
})
.controller('SubCtrl', function($scope) {
$scope.items = [{'val' : 'D'}, {'val' : 'E'}, {'val': 'A'}];
})
.controller('SubSubCtrl', function($scope, $templateCache) {
$scope.items = ['A', 'B', 'C'];
})
.controller('MarkerCtrl', function($scope) {
$scope.getDesc = function() {
switch($scope.category) {
case 'A':
return 'very high';
case 'B':
return 'high';
case 'C':
return 'middle';
case 'D':
return 'low';
case 'E':
return 'very low';
default:
return 'unknown (category is "' + $scope.category + '")';
}
};
})
.directive('sharedMarker', function() {
return {
restrict: 'AE',
controller: 'MarkerCtrl',
template: '<span class="category {{category}}">{{getDesc()}}</span>'
};
})
.directive('marker', function() {
return {
scope: { category : '@' },
restrict: 'AE',
controller: 'MarkerCtrl',
template: '<span class="category {{category}}">{{getDesc()}}</span>'
};
});