javascript - Disable tag with ng-show but not content in AngularJS -
is possible "disable" tag instead of completly hiding content? want enclose content pre-tag if boolean true. ng-show hides complete tag content if boolean false, want remove pre-tag keep content. possible?
my current solution using custom filter, in opinion more hack 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 filter seems quite appropriate honest.
you can hack html this:
<span ng-hide="message.flag"><pre></span>{{message}}<span ng-hide="message.flg"></pre></span>
the w3 validator seems down can't verify valid html if is, wouldn't use solution :)
Comments
Post a Comment