Is it possible to just "disable" a tag instead of completly hiding it with its content? I want to enclose my content with the pre-tag only if a boolean is true. ng-show hides the complete tag with content if the boolean is false, but I only want to remove the pre-tag but keep the content. Is this possible?
My current solution is using a custom filter, but in my opinion this is more a hack than a solution.
angular.module("myApp", []).filter("myText", function ()
{
return function (message)
{
message.text = message.text.trim();
if (message.flag)
{
message.text = "<pre>" + message.text + "</pre>";
}
return message.text;
};
});
Using a filter seems quite appropriate to be honest.
You can probably hack the html like this:
<span ng-hide="message.flag"><pre></span>{{message}}<span ng-hide="message.flg"></pre></span>
The W3 validator seems to be down so I can't verify this is valid html but even if it is, I wouldn't use this solution :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.