0

I am developing an application with Laravel and Angular JS. I am using [[ ]] for data binding.

On binding data in table with ng-switch is getting error and not working.

 <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>

The response Status variable getting string values 1 and 0 when I check with Firebug.

How can I solve this....

I am using Angular JS v1.5.8

Error in Console..

 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
4

1 回答 1

3
<td ng-switch="category.Status">
    <img ng-switch-when="1" ...></td>
    <img ng-switch-when="0" ...></td>

</td>你在第一个之后过早地关闭了img,第二个img在之外<td>,因此也在 的范围之外ng-switch。该错误是由于ng-switch-when="0"无法找到 parent引起的ng-switch

于 2016-10-11T13:16:57.283 回答