javascript - angular js - not assign value to dynamically generated textbox from controller using ng-model -
i have generated dynamic form html using angular js directive , want assign values generated textbox using values provided (values may come database or array)
when not sending parameter dynamically, run following code , assign value textbox
$scope.submitted = function() { $scope.title = "submitted"; };
but when sending dynamic value form not working.
the function got called directive after click , showing alert function value not assigning textbox model. here code
$scope.submitted = function(par) { alert(par); $scope.title = par; };
please findout code on following plunker:
the problem each dynamic
directive compiled in isolated child scope. when later set outer scope property title
not affect local directives scope.
what can inside of $scope.submitted
function set ngrepeat
child scope title , pass value directive scope config object:
$scope.submitted = function(par) { this.title = par; // points individual ngrepeate scope object };
and in directive configuration:
scope: { title: '=model', param1: '@', formfn: '&' },
and use directive this
<div dynamic param1="{{lang}}" form-fn="submitted(lang)" model="title"></div>
Comments
Post a Comment