无法在模态

时间:2017-07-27 18:07:17

标签: angularjs cordova ionic-framework

在模态对话框中,我在单独的跨距中显示值,这些跨距来自对象(例如: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);
};

1 个答案:

答案 0 :(得分:-1)

我会添加一项检查以确保input具有值。你可以这样做:

var ar = input ? input.split(',') : [];