我看了很多,但我要么找不到答案,要么我不明白.一个具体的例子将赢得投票=)
这是我尝试过的:
// My magic HTML string function.
function htmlString (str) {
return "<h1>" + str + "</h1>";
}
function Ctrl ($scope, $compile) {
$scope.htmlString = htmlString;
}
Ctrl.$inject = ["$scope", "$compile"];
Run Code Online (Sandbox Code Playgroud)
那没用.
我也试过它作为一个指令:
// My magic HTML string function.
function htmlString (str) {
return "<h1>" + str + "</h1>";
}
angular.module("myApp.directives", [])
.directive("htmlString", function () {
return {
restrict: "E",
scope: { content: "@" },
template: "{{ htmlStr(content) }}"
}
});
... and in …Run Code Online (Sandbox Code Playgroud) 我有包含链接的字符串,我想让该链接可单击。从角度来看我将如何去做呢?
\n\n以下是我拥有的 json 数据中的字符串示例“I\xe2\x80\x99m 于 9 月 27 日与 @BillieFaiers 一起主持 #AFF Catwalk Show @Bullring。在此处了解更多信息 > http://www.clickhereformoreinfo.com ”
\n\n基本上我希望主题标签、at 符号和链接都是标签。请帮忙解决这个问题几个小时了。
\n