Angularjs 为什么字符串比较失败?

Angularjs 为什么字符串比较失败?,angularjs,foreach,Angularjs,Foreach,基本上,我尝试将事务与类别匹配。我将事务标题发送给一个函数,如果有类别包含具有相同事务标题的关键字,则返回类别id。但它不起作用 怎么了 $scope.data.push({ title: temp[2], category: matchForCategory(temp[2]) }); //Try to match a transaction with a category functio

基本上,我尝试将事务与类别匹配。我将事务标题发送给一个函数,如果有类别包含具有相同事务标题的关键字,则返回类别id。但它不起作用

怎么了

$scope.data.push({
                title: temp[2],
                category: matchForCategory(temp[2]) 
            });

    //Try to match a transaction with a category
    function matchForCategory(transactionTitle){
        var temp = 0;

        angular.forEach($scope.categories, function(c){
            angular.forEach(c.keywords, function(k){
               if(k == transactionTitle)
                        temp =c.id;
            });
        });

        console.log(temp); //Output is always: 0

        if(temp == 0)
            return 'NA';
        else
            return temp;
    }
类别如下:

[...,{
    "id": 13,
    "title": "Utemat",
    "keywords": [
      "MCDONALD S VASAG",
      "PIZZERIA AMORE",
      "BISTRO65"
    ],
    "$$hashKey": "00T"
  },
  {
    "id": 14,
    "title": "Natklubb",
    "keywords": [

    ],
    "$$hashKey": "00V"
  },...]

是否可能是案例不匹配?尝试:

(k.toUpperCase() === transactionTitle.toUpperCase())