angularjs - Access parent data model in directive -
i wrote directive check double values in data column:
the markup
<table> <tr data-ng-repeat-start="rowitem in vm.model.data" ...> <td> <input type="text" data-ng-model="rowitem.id" data-unique-column="vm.model.data" /> </td> ... </tr> </table>
and directive
(function () { 'use strict'; angular.module('app').directive('uniquecolumn', function () { return { restrict: 'a', require: 'ngmodel', link: function (scope, element, attrs, ngmodel) { element.on('keyup blur', function () { scope.$eval(attrs.uniquecolumn).foreach(function (item) { // validation logic }); }); } }; }); })();
everything works fine asked myself if there solution access data of repeater, i.e. vm.model.data, without passing argument directive?
because didn't isolate scope, can read javascript's prototypal inheritance. can perhaps access method child lookup parent's. , perhaps use $index parameter.
Comments
Post a Comment