阻止 AngularJS 编译元素的内容
Prevent AngularJS from compiling contents of element
有没有办法告诉Angular不要编译某些元素的内容?
用例:
Angular CMS 包含 textarea
个附加了 CKEditor 的元素。 CKEditor 使用 divarea 插件而不是默认的 iframe 插件。文本区域包含 HTML 个模板。这些模板按需导出并提供给 Angular webapp。
模板足够简单:纯文本、有序列表、偶尔应用于纯文本的预定义 class 属性;但纯文本可以包含 Angular webapp 的占位符以进行插值。我根本不想让 CMS 中的 Angular 插入这些内容。
目前我的问题是 CMS 中的 Angular 插入了这些占位符,并且由于它们不引用任何内容,因此删除了它们。我宁愿不只是将分隔符更改为“{[”,“]}”,因为虽然这可能会在短期内解决这个问题,但随着项目的进行,指令和文本复制冲突的可能性会增加,我希望避免它。
是否有任何指令或其他方式告诉Angular远离特别标记元素的内容?
在元素上使用 ng-non-bindable
directive:
The ngNonBindable directive tells Angular not to compile or bind the
contents of the current DOM element. This is useful if the element
contains what appears to be Angular directives and bindings but which
should be ignored by Angular.
或者使用你自己的指令和 terminal: true
属性 来更好地匹配布局,因为它是 the only thing that ng-non-bindable
directive does.
有没有办法告诉Angular不要编译某些元素的内容?
用例:
Angular CMS 包含 textarea
个附加了 CKEditor 的元素。 CKEditor 使用 divarea 插件而不是默认的 iframe 插件。文本区域包含 HTML 个模板。这些模板按需导出并提供给 Angular webapp。
模板足够简单:纯文本、有序列表、偶尔应用于纯文本的预定义 class 属性;但纯文本可以包含 Angular webapp 的占位符以进行插值。我根本不想让 CMS 中的 Angular 插入这些内容。
目前我的问题是 CMS 中的 Angular 插入了这些占位符,并且由于它们不引用任何内容,因此删除了它们。我宁愿不只是将分隔符更改为“{[”,“]}”,因为虽然这可能会在短期内解决这个问题,但随着项目的进行,指令和文本复制冲突的可能性会增加,我希望避免它。
是否有任何指令或其他方式告诉Angular远离特别标记元素的内容?
在元素上使用 ng-non-bindable
directive:
The ngNonBindable directive tells Angular not to compile or bind the contents of the current DOM element. This is useful if the element contains what appears to be Angular directives and bindings but which should be ignored by Angular.
或者使用你自己的指令和 terminal: true
属性 来更好地匹配布局,因为它是 the only thing that ng-non-bindable
directive does.