2017-07-27 62 views
-1

在模式對話框中,我顯示了來自對象(例如:skill1,skill2,skill3)的單獨跨度中的值。一切運作良好。但是,我收到錯誤消息TypeError: Can not read property' split 'of undefined in App.js無法讀取模態中未定義的屬性「拆分」

HTML

<div class="matchSkills"> 
    <span class="tags t-vg ion-trophy icon-tag matchTagVg" 
      ng-repeat="skillsVeryGood in (skillsVeryGood | commaSplit)"> 
     {{ skillsVeryGood }} 
    </span>     
    <span class="tags t-g ion-ribbon-a icon-tag matchTagG" 
      ng-repeat="skillsGood in (skillsGood | commaSplit)"> 
    {{ skillsGood }} 
    </span>     
</div> 

app.js

// comma separating filter 

.filter('commaSplit', function() { 
    return function(input) { 
    //console.log(input); 
    var ar = input.split(','); // this will make string an array 
    return ar; 
    }; 
}) 

controller.js

$ionicModal.fromTemplateUrl('templates/infoPerson.html', function(modalPersonInfo) { 
    $scope.modalPersonInfo = modalPersonInfo; 

}, { 
    scope: $scope, 
}); 


// Open the modal Person Info 

$scope.PersonInfo = function(chat) { 
    $scope.skillsGood = chat.skillsGood; 
    $scope.skillsVeryGood = chat.skillsVeryGood; 
    $scope.modalPersonInfo.show(chat); 
}; 
+0

更改代碼這樣如果{VAR AR = input.split( '');} – Vivz

+1

謝謝Vivz,它的工作原理(輸入=未定義!)! – mm1975

+1

很高興能有幫助:) – Vivz

回答

-1

我想補充一個檢查,以確保日在input有一個值。你可以這樣做:

var ar = input ? input.split(',') : []; 
相關問題