Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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 ?

share|improve this question
    
What do you want – Ghazanfar Khan Dec 25 '16 at 21:18
    
$scope.myText = "My name is:John Doe"; – zafer Dec 25 '16 at 21:44

Update your code

<p ng-bind-html="myText"></p> 
share|improve this answer
<div ng-app="myApp" ng-controller="myCtrl">
    <p ng-bind-html="1"></p>
</div>
<div ng-app="myApp" ng-controller="myCtrl">
    <p ng-bind-html="2"></p>
</div>
<div ng-app="myApp" ng-controller="myCtrl">
    <p ng-bind-html="3"></p>
</div>
<div ng-app="myApp" ng-controller="myCtrl">
    <p ng-bind-html="4"></p>
</div>
<div ng-app="myApp" ng-controller="myCtrl">
    <p ng-bind-html="5"></p>
</div>
.
.
.

How do I print data?

share|improve this answer
up vote 0 down vote accepted

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>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.