-1

I am developing my application with angularjs and ionic,

<div ng-app="myApp" ng-controller="myCtrl">

    <p ng-bind-html="{{itemID}}"></p>

</div>

I would like to change this to angularjs like innerHTML,

<script>
var app = angular.module("myApp", ['ngSanitize']);
app.controller("myCtrl", function($scope) {
    $scope.myText = "My name is:John Doe";
});
</script>

This is not because it needs to write itemid instead of $scope.myText.

How can I do it uniquely as above ?

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
zafer
  • 29
  • 7

2 Answers2

1

Update your code

<p ng-bind-html="myText"></p> 
Ghazanfar Khan
  • 3,648
  • 8
  • 44
  • 89
0

I solved the problem. controller.js

$scope.myText={};


    var app = angular.module("myApp", ['ngSanitize']);
    app.controller("myCtrl", function($scope,$itemID) {
        $scope.myText{$itemID} = "My name is:John Doe";
    });

html page

<div ng-app="myApp" ng-controller="myCtrl">
    <p ng-bind-html="myText[$itemID]"></p>
</div>
zafer
  • 29
  • 7