Ng-Readonly-3

 
There are list of options of fields array of object.On the basis of selected value we can enable that particular input field active.But by default all input fields are readonly because novalue is selected from dropdownlist.
 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="controllerName"> Read field : <select ng-model="fieldname" ng-options="p.name as p.name for p in fields"></select><br /><br /> Date:<input ng-readonly="fieldname!='Date'" type="date" ng-model="name2"><br /> Time:<input ng-readonly="fieldname!='Time'" type="time" ng-model="name1"><br /> Month:<input ng-readonly="true && fieldname!='Month'" type="month" ng-model="name4"><br /> Week:<input ng-readonly="fieldname!='Week'" type="week" ng-model="name3"> </div> <script> var app = angular.module("app", []); app.controller('controllerName', ['$scope', function ($scope) { $scope.fields = [{ name: 'Date' }, { name: 'Time' }, { name: 'Month' }, { name: 'Week' }]; }]); </script> </body> </html>
Output