ng如果没有'如果条件文本在AngularJs中包含空格,则不起作用
ng-if doesn't work if condition text contains space in AngularJs
我试图根据row.entity值将值设置到Angular js-Ui网格中。为了做到这一点,我创建了cellTemplate来检查行值,并基于这些值进行了一些文本样式设置。
代码段
var statusTemplate='<div>
<span class="txt-color-yellow" ng-if=row.entity.status.name=="Draft">{{row.entity.status.name}}</span>
<span class="txt-color-orange" ng-if=row.entity.status.name==[
"AwaitingReview"]>{{row.entity.status.name}} </span><span
class="txt-color-green" ng-if=row.entity.status.name=="Reviewed">{{row.entity.status.name}}
</span><span class="txt-color-blue" ng-if=row.entity.status.name==[ "Ready ForScripting"]>{{row.entity.status.name}}</span><span
class="txt-color-brown" ng-if=row.entity.status.name==[ "Awating
ScriptReview"]>{{row.entity.status.name}}</span><span
class="txt-color-green" ng-if=row.entity.status.name==[ "ScriptReviewed"]>{{row.entity.status.name}}</span><span
class="txt-color-green" ng-if=row.entity.status.name=="Closed">{{row.entity.status.name}}</span>
';
但问题出在ng-if
中,当尝试用空格检查文本值时,它抛出了一个异常,称为Unterminated quote at columns 25-34 ["Awaiting] in expression [row.entity.status.name==["Awaiting]. etc...
。
请告诉我如何检查带空格的文本。
在所有div中更改它,其中类似写入的字符串在单''
中传递,条件在双引号""
中写入
ng-if="row.entity.status.name=='Draft'"
您必须将条件放入"
中。所以以下内容应该会有所帮助。
ng-if="row.entity.status.name=='Draft'"
您应该有ng if的引号,试试这个ng-if="row.entity.status.name==['"Awaiting Review}'"]"
如果="row.entity.status.name='''Draft'''"
相关文章:
- 如何包含特定于每个视图angularjs的javascript文件
- AngularJs-$route.current到底包含什么
- ng-class 在 angularJs 中由 ng-include 包含的文件内不起作用
- AngularJS应用程序:如何将.js文件包含到index.html中
- Angularjs:如何检查元素的子元素是否包含某些元素(通过ID)
- 如何将文件夹中包含的控制器动态绑定到angularjs中的视图
- AngularJS指令未包含在父元素中
- 是否可以将我网站上的普通javascript和css函数包含到我的angularjs应用程序中
- AngularJS:如何使用ng repeat来显示父数组中包含的数组的所有元素
- AngularJS:触发对包含过滤器的绑定的评估
- javascript标记中包含变量的AngularJS JSON数组
- 如何使用 RESTful 访问加载包含 AngularJS 的 HTML
- 如何在 JavaScript 函数中包含 AngularJS 变量
- 如何使用jquery添加包含AngularJS表达式的ajax加载内容
- 如果一行包含Angularjs的特定项目,则高亮显示该行
- 如何在 Rails 应用程序中包含 AngularJS 库文件
- 在页面中包含angularjs脚本的正确方法
- 在Javascript中包含AngularJS库时出错
- 如何包含一个包含angularjs绑定的html作为弹出模式
- I'在包含Angularjs代码后,我无法在Chrome中右键单击我的网页