I have been trying to define directives so I can display different \"widgets\" in a form, depending on the type of field and its parameters, which are stored in a database.
I don't know why you are triggering the $apply method manually because you actually don't need it.
I edited the example you used from the Angular page and included the input. It works for me: http://jsfiddle.net/6HcGS/2/
HTML
Title:
JS
function Ctrl3($scope) {
$scope.title = 'Lorem Ipsum';
}
angular.module('zippyModule', [])
.directive('zippy', function(){
return {
restrict: 'C',
replace: true,
transclude: true,
scope: { title:'=zippyTitle' },
template: '',
link: function(scope, element, attrs) {
// Your controller
}
}
});
UPDATE
maxisam is right, you have to use ng-model instead of binding the variable against the value like so:
Here is the working version: http://jsfiddle.net/6HcGS/3/