简体   繁体   English

修改元素从AngularJs获取

[英]Modify elements get from AngularJs

I have a Paragraph gets from angularjs by using 我有一个段落从angularjs通过使用

<p>{literal}<p ng-bind-html="toTrust(article._data.abstract)"></p>{/literal}</p>

the result would be an example like 结果将是一个类似的例子

Introduction aaaaaaaaaa, Methods bbbbbb

I want to modify it, to make Introduction in one line, and the methods in the other line like 我想修改它,在一行中做Introduction,在另一行中做方法,例如

Introduction aaaaaa
Methods bbbbbb

I tried add a script below it to do this, but AngularJs seems not load it correctly. 我尝试在其下添加脚本来执行此操作,但是AngularJs似乎无法正确加载它。

actually, i am very new to angular, and the idea I tried was using jQuery to find this paragraph and pass into a regular expression function to rewrite the whole paragraph but since the paragraph input directly from the angular ng-bind-html. 实际上,我对angular非常陌生,而我尝试的想法是使用jQuery查找该段落并传递给正则表达式函数以重写整个段落,但由于该段落是直接从angular ng-bind-html输入的。 so I have no idea how to pass it into a regular expression function 所以我不知道如何将其传递给正则表达式函数

I dont know whats the other ways to do it? 我不知道还有其他方法吗?

You could create a filter to replace commas with new lines. 您可以创建一个过滤器以用新行替换逗号。

Something like: 就像是:

App.filter('myFilter', function () {
    return function(text) {
        return text.replace(',', '<br/>');
    }
})

Should be able to implement it like this: 应该能够像这样实现它:

<p>{literal}<p ng-bind-html="toTrust(article._data.abstract) | myFilter"></p>{/literal}</p>

Have not tested it though! 虽然还没有测试!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM