Angular Ionic 框架的 JS 内部 Html
Angular JS Inner Html for Ionic Framework
我正在使用 angularjs 和 ionic
开发我的应用程序
<div ng-app="myApp" ng-controller="myCtrl">
<p ng-bind-html="{{itemID}}"></p>
</div>
我想将其更改为 angularjs,如 innerHTML,
<script>
var app = angular.module("myApp", ['ngSanitize']);
app.controller("myCtrl", function($scope) {
$scope.myText = "My name is:John Doe";
});
</script>
这不是因为需要写itemid而不是$scope.myText.
我怎样才能像上面那样独特地做到这一点?
更新您的代码
<p ng-bind-html="myText"></p>
我解决了这个问题。
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 页
<div ng-app="myApp" ng-controller="myCtrl">
<p ng-bind-html="myText[$itemID]"></p>
</div>
我正在使用 angularjs 和 ionic
开发我的应用程序<div ng-app="myApp" ng-controller="myCtrl">
<p ng-bind-html="{{itemID}}"></p>
</div>
我想将其更改为 angularjs,如 innerHTML,
<script>
var app = angular.module("myApp", ['ngSanitize']);
app.controller("myCtrl", function($scope) {
$scope.myText = "My name is:John Doe";
});
</script>
这不是因为需要写itemid而不是$scope.myText.
我怎样才能像上面那样独特地做到这一点?
更新您的代码
<p ng-bind-html="myText"></p>
我解决了这个问题。 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 页
<div ng-app="myApp" ng-controller="myCtrl">
<p ng-bind-html="myText[$itemID]"></p>
</div>