2016-01-04 43 views
-3

我有數組中的值與單詞之間的空間獲取錯誤我將替換空間問題將被修復,但在U.I我想在空間中顯示它。吳重複獲取錯誤之間的空間

代碼

<td ng-repeat="measure in subsystem.measures track by $index" ng-show={{measure.measureType}}> 
     <h4><b>{{measure.measureType}}</b> </h4> 
</td> 

值:EB Bill`

錯誤:

[$parse:syntax] Syntax Error: Token 'Bill' is an unexpected token at column 5 of the expression [EB Bill] starting at [Bill]. 
+0

表現出一定的樣本數據,問題就沒有意義了 – charlietfl

+0

爲什麼不使用CSS上課帶來的差距? – mido

回答

2

的問題是ng-show應該評估爲trusy ......但是 'EB比爾' 沒有按」評估任何事情。如果刪除ng-show指令,那麼它應該工作...見下文......

var app = angular.module("myApp", []); 
 

 
app.controller("testcontroller", ["$scope", 
 
    function($scope) { 
 
    //$scope.measure.measureType = "EB Bill"; 
 
    $scope.subsystem = { 
 
     measures: [{ 
 
     measureType: 'one' 
 
     }, { 
 
     measureType: 'two and three' 
 
     }, { 
 
     measureType: 'EB Bill' 
 
     }] 
 
    }; 
 
    } 
 
]);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script> 
 

 
<div ng-app="myApp" ng-controller="testcontroller"> 
 
    <div ng-repeat="measure in subsystem.measures track by $index"> 
 
    <h4><b>{{measure.measureType}}</b> </h4> 
 
    </div> 
 
</div>

+0

是的,我們如何顯示它在ng-show –

+0

那不是如何'ng顯示'工作...它簡單地評估一個表達式,如果表達式是trusy元素被顯示,如果表達式評估爲falsy那麼表達式是未顯示... – Leo

1

You must have true or false value for ng-show, Try to have only true or false data for measureType property, I am sure you will not get this error.

相關問題