首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ng-bind-html不处理输入

ng-bind-html不处理输入
EN

Stack Overflow用户
提问于 2014-01-13 22:59:15
回答 1查看 98关注 0票数 1

我想将html与$scope.value = "<input type=text name=a>"的内容绑定在一起

没有任何东西被插入到DOM中,但是如果使用$scope.value = "Hello <i>Guys</i>",一切都是正常的。

ng-bind-html是否有限制/bug?有解决办法吗?

我使用的是1.2.4版本的angularJS

谢谢你的帮助,这对我的发展来说是个大问题

克里斯托弗

EN

回答 1

Stack Overflow用户

发布于 2014-01-14 00:25:39

你不能用一个指令来代替它吗?这样我想你就摆脱了你的问题

http://docs.angularjs.org/guide/directive

https://egghead.io/search?q=directive

下面是一个小示例:

代码语言:javascript
复制
angular.module('myApp').directive('myDirective', function(){
  return {
    restrict: 'E',
    replace: true,
    // you can set 'transclude: true' instead of the following line to create a new scope but inheriting from the parent
    scope: false, // this will make the directive have the same scope as the parent
    templateUrl: 'my-html-template.html'// you can load the template like this
    // You can also use 'template' and include the html code here
  }
});
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21094362

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档