1

How to concatenate string with scope variable and assign it to ng-model

is there a way ti express this

ng-model="'is'+location.placeName+'Checked'"
Mo Haidar
  • 3,748
  • 6
  • 37
  • 76
  • You can write javascript expression inside ng-model directive. Your code should work, check this : http://stackoverflow.com/questions/12553617/how-can-i-set-a-dynamic-model-name-in-angularjs – Supradeep Oct 05 '16 at 13:03

2 Answers2

0

You can use ng-bind-model instead of ng-model in this case

ng-bind-model="is{{location.placeName}}Checked"

thanks

Ujjwal kaushik
  • 1,618
  • 11
  • 17
0

Finally found the answer randomly in this plunker by ozkary using ng-init

HTML View

<input ng-model="isPlaceChecked" ng-init="isPlaceChecked = checkIfPlaceChecked(location.placeName)"

JS Controller

    $scope.checkIfPlaceChecked = function (placeName) {
        return "is" + placeName + "Checked";
    }
sigmapi13
  • 2,355
  • 3
  • 30
  • 27