-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
45 lines (37 loc) · 958 Bytes
/
script.js
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
var app = angular.module('app', []);
app.controller('MainCtrl', function MainCtrl($timeout) {
var vm = this;
vm.goodFoo = {
isFoo: true,
isBar: false,
someNum: 32
};
$timeout(function() {
vm.badFoo = '';
}, 1500);
});
app.constant('scopeTypesDirective', angularScopeTypes().directive);
app.directive('scopeTypedDir', function(scopeTypesDirective) {
return scopeTypesDirective({
template: `
<div>
This was scope type checked!
<div>Passed: {{$scopeTypesResults.__passed}}</div>
<div>Failed: {{$scopeTypesResults.__failed}}</div>
</div>
`,
scope: {foo: '=', bar: '@'},
scopeTypes: getScopeTypes
});
function getScopeTypes(st) {
return {
foo: st.shape({
isFoo: st.bool,
isBar: st.bool,
someNum: st.number,
someOptional: st.object.optional
}).strict.optional,
bar: st.oneOf(['fooString', 'barString'])
};
}
});