大佬教程收集整理的这篇文章主要介绍了AngularJS 1.2.0 ngBindHtml和trustAsHtml不能与ngModel一起使用,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这基本上是我在阅读的内容中使用的格式:
var myApp = angular.module('myApp',[]); function myController($scope,$scE){ $scope.myHtml = $sce.trustAsHtml($scope.sourCEText); }
HTML:
<html ng-app="myApp"> <head> <script data-require="angular.js@1.2.0-rc3" data-semver="1.2.0-rc3-nonmin" src="http://code.angularjs.org/1.2.0-rc.3/angular.js"></script> <link rel="stylesheet" href="style.css" /> <script src="script.js"></script> </head> <body> <div ng-controller="myController"> <textarea ng-model="sourceText"></textarea> <div ng-bind-html="myHtml"></div> </div> </body> </html>
我认为这将是直截了当的,但我一定是错的,错过了一些东西.
我把这个简单的例子放到了Plunker:http://plnkr.co/edit/ZX4dONBlzv1X8BcO1IBV?p=preview
// would strongly suggest including sanitize in your scripts and injecTing it // into your app here to prevent "unsafe as safe" errors var myApp = angular.module('myApp',['ngSanitize']); myApp.controller('myController',['$scope','$sce',function myController($scope,$scE){ $scope.myHtml = "initial"; //not needed,for tesTing $scope.changeText = function() { $scope.myHtml = $sce.trustAsHtml($scope.sourCEText); } }]);
HTML:
<head> <script data-require="angular.js@1.2.0-rc3" data-semver="1.2.0-rc3-nonmin" src="http://code.angularjs.org/1.2.0-rc.3/angular.js"></script> <script src="http://code.angularjs.org/1.2.0-rc.3/angular-sanitize.min.js"></script> <link rel="stylesheet" href="style.css" /> <script src="script.js"></script> </head> <body> <div ng-controller="myController"> <textarea ng-model="sourceText" ng-change="changeText()"></textarea> <div ng-bind-html="myHtml"></div> </div> </body> </html>
以上是大佬教程为你收集整理的AngularJS 1.2.0 ngBindHtml和trustAsHtml不能与ngModel一起使用全部内容,希望文章能够帮你解决AngularJS 1.2.0 ngBindHtml和trustAsHtml不能与ngModel一起使用所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。