0

I have selected user from search in Js function currently input field is readOnly , So once we have value from selectedOwner i want to change input field background color to white because user don't want to see gray color that is coming from readOnly directive ? Is there way to implement this kind of requirement ?

main.html

<div class="form-group col-md-6">
                    <div class="col-md-6">
                        <label class="control-label required" for="rcsaOwner">RCSA
                            Owner :</label>
                    </div>
                    <div class="col-md-6">
                        <input type="text" class="form-control" id="rcsaOwner" required ng-class="{'background1': color.back}"
                            ng-model="riskAssessmentDTO.rcsaOwnerWorker" name="rcsaOwnerWorker"
                            ng-click="openRcsaOwner()" ng-model-options="{updateOn: 'blur'}" ng-readOnly="true"/>
                        <p class="text-danger"
                            ng-show="addAssessment.rcsaOwnerWorker.$touched && addAssessment.rcsaOwner.$error.required">RCSA
                            Owner is required</p>
                    </div>
                </div>

mainCtrl.Js

    $scope.selectedOwner = function (selectedOwner, workerKey) {
        this.$parent.$parent.rcsaOwnerModal.close();
        $scope.riskAssessmentDTO.rcsaOwnerWorkerKey = workerKey;
        $scope.riskAssessmentDTO.rcsaOwnerWorker = selectedOwner;
        $scope.color = { back: true};
    };

main.css

.background1 {
      background-color: #eeee12;
      color: red;

}
Nicholas K
  • 15,148
  • 7
  • 31
  • 57
aftab
  • 535
  • 4
  • 13
  • 46
  • What's the question? You seem to have something that should work using `ng-class`. – isherwood Jul 13 '15 at 16:06
  • yes i want to change input background color once value is selected ,with current implementation its not changing background with readOnly – aftab Jul 13 '15 at 16:22
  • Are you seeing any errors in the console? Have you stepped through to make sure it's working as expected? – isherwood Jul 13 '15 at 16:23
  • No error in console , its changing font color as expected but not the background color – aftab Jul 13 '15 at 16:27
  • Ah. Then this is a CSS selector issue and has nothing to do with AngularJS. Use your document inspector to find out what's trumping your rule, and rectify that with specificity. – isherwood Jul 13 '15 at 16:27
  • I think you are not getting my point its not selector issue, when you use readOnly background is by default gray.can we change background color to white with css implementation or not ? – aftab Jul 13 '15 at 16:32
  • http://stackoverflow.com/questions/9635293/how-to-style-readonly-attribute-with-css – isherwood Jul 13 '15 at 16:34

0 Answers0