This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayground.html
48 lines (42 loc) · 1.55 KB
/
playground.html
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
<!DOCTYPE html>
<html>
<head>
<script data-require="[email protected]" data-semver="1.7.0" src="https://code.angularjs.org/1.7.0/angular.js"></script>
<script src="https://rawgit.com/KevinRamharak/ng-sane-defaults/master/dist/ng-sane-defaults.js"></script>
<script>
let checkNull = true; // toggling this well change test2
let i = 0;
class ComponentTagController {
static get $defaults() {
return {
text: `component #${++i}`
};
}
}
angular.module('myApp', ['ng-sane-defaults']).component('componentTag', {
template: '<p>{{ $ctrl.text }}</p>',
bindings: {
text: '<'
},
controller: ComponentTagController
}).run(['$rootScope', 'defaultsConfig', function ($rootScope, defaultsConfig) {
$rootScope.test1 = undefined;
$rootScope.test2 = null;
$rootScope.test3 = 'text supplied by variable';
console.log(defaultsConfig);
}]).config(['defaultsConfigProvider', function (provider) {
provider.$get().checkNull = checkNull;
}]);
</script>
</head>
<body ng-app="myApp">
<!-- defaults -->
<component-tag></component-tag>
<component-tag text="test1"></component-tag>
<component-tag text="test2"></component-tag>
<!-- non defaults -->
<component-tag text="test3"></component-tag>
<component-tag text="'text supplied by literal expressoin'">
</compontent-tag>
</body>
</html>