blob: 84032bdd9ef10d6ba7ccf36f63fc15fb03ab2ac2 (
plain)
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
|
angular.directive("auth", function(expression, element){
return function(){
if(expression == "eager") {
this.$users.fetchCurrent();
}
};
});
//expression = "book=Book:{year=2000}"
angular.directive("entity", function(expression, element){
//parse expression, ignore element
var entityName; // "Book";
var instanceName; // "book";
var defaults; // {year: 2000};
parse(expression);
return function(){
this[entityName] = this.$datastore.entity(entityName, defaults);
this[instanceName] = this[entityName]();
this.$watch("$anchor."+instanceName, function(newAnchor){
this[instanceName] = this[entityName].get(this.$anchor[instanceName]);
});
};
});
|