Last active
December 23, 2015 11:19
-
-
Save mllrjb/6627721 to your computer and use it in GitHub Desktop.
Angular directive to support expressions in `input.name`, pending merge of https://github.com/angular/angular.js/pull/3135.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.directive('ngName', function() { | |
return { | |
restrict: 'A', | |
require: ['^form', 'ngModel'], | |
link: function($scope, ele, attr, ctrl) { | |
var formCtrl = ctrl[0]; | |
var ngModel = ctrl[1]; | |
var name = $scope.$eval(attr.mppName); | |
if (ngModel.$name != name) { | |
formCtrl.$removeControl(ngModel); | |
ngModel.$name = name; | |
attr.$set('name', name); | |
formCtrl.$addControl(ngModel); | |
} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based off angular/angular.js#2988