I'm not sure, but here is what you can try:
ng-change="prmnt_a2 = (same)?prmnt_a1:''"
Here is a complicated but complete HTML way that should work:
<div ng-if="same==false"> <input type="text" id="prmnt_a2" ng-model="prmnt_a2" class="customInput" placeholder="Address Line 2"/> </div> <div ng-if="same==true"> <input type="text" id="prmnt_a2" ng-init="prmnt_a2=prmnt_a1" disabled ng-model="prmnt_a2" class="customInput" placeholder="Address Line 2"/> </div>
Note: ng-init is not used as usual, and be sure to use ng-if, not ng-show / hide.
Otherwise, if this does not work: a custom directive or the / $ watch function in the controller. ng-attr just won't work here.
EDIT: for a custom directive, this will look like code:
.directive('myDirective', function(){ return{ restrict : 'A', scope:{ same:'=myBoolean' value:'=myValue' }, require:'ngModel', link:function(scope, element, attr, ngModelCtrl){ scope.$watch('same', function(newValue){ if(newValue){ ngModel.setViewValue(scope.value); } }); } } } <input type="text" id="prmnt_a2" ng-init="prmnt_a2=prmnt_a1" ng-disabled="same" ng-model="prmnt_a2" my-directive my-boolean="same" my-value="prmnt_a1" class="customInput" placeholder="Address Line 2"/>
This directive is quite simple. If you need more complex things, check the online documentation.
source share