Cannot Set Property '$render' Of Undefined
Please need help with this error 'Cannot set property '$render' of undefined'. I know that this question is already asked but i cant solve it. $scope.editmode = false; $scope.t
Solution 1:
If you are using ngModel in link function you should require it in directive
return {
require: 'ngModel', // <---THIS
link: function(scope, element, attrs, ngModel) {
functionread() {
ngModel.$setViewValue(element.html());
}
ngModel.$render = function() {
element.html(ngModel.$viewValue || "");
};
element.bind("blur keyup change", function() {
scope.$apply(read);
});
}
Solution 2:
require ngModel in your directive.
directives.directive("contenteditable", function () {
return {
require: 'ngModel',
link: function(scope, element, attrs, ngModel) {
functionread() {
ngModel.$setViewValue(element.html());
}
ngModel.$render = function() {
element.html(ngModel.$viewValue || "");
};
element.bind("blur keyup change", function() {
scope.$apply(read);
});
}
}
}
You could refer to this existing SO post for a detailed explanation regarding ngModel.
Post a Comment for "Cannot Set Property '$render' Of Undefined"