簡體   English   中英

Angular JS ng-switch不起作用

[英]Angular JS ng-switch not working

我正在使用Laravel和Angular JS開發應用程序。 我正在使用[[]]進行數據綁定。

用ng-switch綁定表中的數據時出現錯誤,無法正常工作。

 <tr ng-repeat="category in categories">
            <td>[[category.Name]]</td>
            <td>[[category.ListOrder]]</td>
            <td ng-switch="category.Status">
              <img ng-switch-when="1" src="{{URL::asset('public/assets/images/icons/ic_active.png')}}"></td>
              <img ng-switch-when="0" src="{{URL::asset('public/assets/images/icons/ic_inactive.png')}}"></td>
            <td>
              <img src="{{URL::asset('public/assets/images/icons/ic_inactive.png')}}">
            </td>
            <td>[[category.updated_at]]</td>
</tr>

使用Firebug檢查時,響應狀態變量獲取字符串值1和0。

我該如何解決...

我正在使用Angular JS v1.5.8

控制台錯誤。

 Error: [$compile:ctreq] http://errors.angularjs.org/1.5.8/$compile/ctreq?p0=ngSwitch&p1=ngSwitchWhenN/<@http://localhost/repos/p3-laravel/ppp_admin/public/js/angular.min.js:6:412
<td ng-switch="category.Status">
    <img ng-switch-when="1" ...></td>
    <img ng-switch-when="0" ...></td>

您過早關閉了第一個img之后的</td> ,第二個img<td>之外,因此也在ng-switch的范圍之外。 該錯誤是由ng-switch-when="0"無法找到父ng-switch

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM