将$ scope.country.adtranTL1GatewayIPAddress转换为angularjs中的字符串

时间:2016-02-26 18:12:22

标签: angularjs

我有一个像getParentSys.query({tl1Address: '172.28.71.155'}这样的休息电话 哪个工作正常,但我想将$scope.country.adtranTL1GatewayIPAddress变量中的ips作为变量放入其余的调用中。

HTML:

<input type="text" name="adtranTL1GatewayIPAddress" id="adtranTL1GatewayIPAddress" ng-model="country.adtranTL1GatewayIPAddress" data-toggle="tooltip" data-placement="right" title="<html>IP Address of the Adtran<br>TL1 gateway.<br>Consult your Network Administrator<br>for this value." />
<label for="adtranTL1GatewayIPAddress">Adtran TL1 Gateway IP Address</label>

控制器:

function EightXXCtrl($scope, getParentSys) {
    $scope.getServingTA5000_8xx = function() {
        var matchingScope = "'" + $scope.country.adtranTL1GatewayIPAddress + "'";
        getParentSys.query({
            tl1Address: '172.28.71.155'
        }, function() {
            $scope.log = "User saved";
        }, function() {
            $scope.log = "User could not be saved";
        });
    }
}

请帮忙

1 个答案:

答案 0 :(得分:0)

在看到你如何实现你的html并没有完整的服务代码之后。我假设您需要将$scope.country.adtranTL1GatewayIPAddress嵌入为字符串。看到您的代码,getParentSys必须是您的service

只需在您的控制器中

IF getParentSys.query({tl1Address: '172.28.71.155'});

yourApp.controller('testController',function($scope,getParentSys){
       $scope.matchingScope = "'"+$scope.country.adtranTL1GatewayIPAddress+"'";
       getParentSys.query({tl1Address: $scope.matchingScope});
})

IF getParentSys.query({'tl1Address': '172.28.71.155'});

yourApp.controller('testController',function($scope,getParentSys){
           $scope.matchingScope = "'"+$scope.country.adtranTL1GatewayIPAddress+"'";
           getParentSys.query({'tl1Address': $scope.matchingScope});
    })
  

还有其他方法可以实现上述目标。