I have not been able to find just documentation on what can be done with templates like mustache or twig. All documentation is a bit of this a bit of that but not a clear list of what you can do with the template.
Trying to write a directive that will generate text and a checkbox. The code if a checkbox needs to be checked is in a function but have no idea how to call it from the template:
In the template:
<input type="checkbox" {{ isChecked(tag) }} />
In the directive:
link : function(scope, iElement, iAttrs, ngModelCtrl) {
scope.isChecked = function(item){
console.log("in ischecked",item,this,arguments);
return "";
};
}
[update]
The reason why I want to do this is because on the server I'm using doctrine and my entities can be filled from JSon. So after a user edits/creates an entity and it's related entities it can be posted as JSON where it'll persist (in a MySQL db).
Problem is that when I remove a related entity (for example a tag from an article) then Angular removes this from the article. I want the article to stay but have a clientCommandRemove property of true so when creating an article entity from posted JSON it knows what to do (remove the tag).
The article should look something like this:
{"text":"some text",id:22,
"tags":[
{"id":6,"clientCommandRemove":true},
{"id":2,"clientCommandAdd":true},
{"id":9}]
}
This tells the entity to take article with id 22 and set the text to "some text" (there are more values but since they're not in the json message they won't change). The tag with id 6 needs to be removed, the tag with id 2 needs to be added and tag with id 9 is unchanged so the Entity won't take any action on this.
As mentioned before; it seems that Angularjs just removes sub objects when using something like ng-options with a multi select so the only way for the entity to update on such information is remove all the tags and add those in the posted article.