I'm trying to change the value of this.foo in my controller to "Bar" from my directive. This is my directive:
.directive('contenteditable', [
function() {
return {
restrict: 'A', // only activate on element attribute
require: '?ngModel', // get a hold of NgModelController
controller: SearchCtrl,
link: function(scope, element, attrs, ngModel) {
scope.foo = "Bar";
}
};
}
]);
This is my controller:
function SearchCtrl() {
this.foo = "hello";
}
I'm removing a lot of code for simplicity, but the directive and the controller are linked up properly and to the same module.