I have a json that I want in a ng-repeat show an input per item for editing.
The json:
$scope.setup.configuration = {
"filename": "configuration",
"fileversion": "01.00.0000"
};
The directive (uses "=" in scope for two ways binding):
app.directive("kSetupOption", ['$rootScope',function ($rootScope) {
return {
scope:{
key:"=",
option:"="
},
restrict: 'E',
template:'<p>{{key}}: <input ng-model="option" /></p>',
link: function (scope, element, attrs) {
}
}
}]);
The problem is that the 2 way binding works correctly with this:
<input ng-model="setup.configuration.filename">
But not with this code using the directive:
<k-setup-option
ng-repeat="(key , option) in setup.configuration"
option="option"
key="key" ></k-setup-option>
Please see the demo in Plunker . thanks.