1
我必须在我的超薄文件中合并角度,我不知道如何转换if else块的角度。我知道角不必如果else语句纳克,但有什么办法下面的代码更改为角if else if else in angular js
- if @cart['empty']
cart is empty
- elsif @cart['invalid']
can't proceed
- else
[email protected]['Items'].each do |item|
#{item['description']}
我要实现一些这样的事
ng-if="cart.empty"
cart is empty
ng-else-if cart.invalid
can't proceed
ng-else
ng-repeat="cart.Items as item"
item.description
这种想法是有道理的。但是,如果rails控制器返回错误,就像@error包含错误消息并且没有购物车变量。如何在交换机模块中添加该条件(如果有错误)。 –
@tumati假设你在你的作用域中有错误,给函数'ng-switch =“getStatus(cart,error)”提供错误“,getStatus将返回'错误',这是一个新的ng-switch'语句。现在你知道'ng-switch'可以开发任何方法,我们不能为你做所有事情 – floribon