I am trying to get simple data binding to work inside a directive template in an Angular setup.
I currently have:
app.directive('myDirective', function() {
return {
replace: true,
restrict: 'E',
templateUrl: "/app/partials/template.html"
}
});
Inside my template.html, I have a simple input field, like so:
<input type="text" ng-model="name" />
My name is {{name}}
However, it displays '{{name}}' rather than the value typed into the input field.
If I copy this input field above outside the directive, it works.
Am I missing something when it comes to data binding within directive templates?
EDIT:
OK. One thing i missed out here as i didn't think it was relevant was this within my directive:
compile:function(){
return function link(scope,element){
// Call a function
steps();
}
}
The reason for this was i needed to fire a Jquery function that controls elements within the template.html.
Removing this resolves the issue, but no javascript within my template works.
Is there an easy way of calling functions within a directive template on compile?