2016-02-26 25 views
0

我有一個休息電話,如getParentSys.query({tl1Address: '172.28.71.155'} 它工作正常,但我想把IP多數民衆贊成在$scope.country.adtranTL1GatewayIPAddress變量到休息調用作爲變量。

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

所以用變量替換字符串...不復雜 – charlietfl

+0

使用getParentSys.query($ scope.country.adtranTL1GatewayIPAddress) –

+1

@AlexRumbaNicked這不是正確的假設變量是一個IP字符串值。然而,OP需要顯示'scope.country'的更多細節是 – charlietfl

回答

0

看到你是如何實現你的HTML和沒有該服務的完整的代碼之後。我假設你需要將$scope.country.adtranTL1GatewayIPAddress作爲一個字符串嵌入。看到您的代碼,getParentSys必須是您的service

只需在您的控制器:

IFgetParentSys.query({tl1Address: '172.28.71.155'});

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

IFgetParentSys.query({'tl1Address': '172.28.71.155'});

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

的其他方法也可以實現上述目的。

+0

在下面的代碼了var線似乎使得該應用失敗 – user3934365

+0

功能EightXXCtrl($範圍,getParentSys){\t $ scope.getServingTA5000_8xx =函數(){ \t VAR matchingScope = 「'」 + $範圍。 country.adtranTL1GatewayIPAddress + 「'」; \t getParentSys.query({tl1Address: '172.28.71.155'},函數(){ \t $ scope.log = 「用戶保存」; },函數(){ \t $範圍。日誌=「用戶無法保存」; }); } } – user3934365

+0

使用範圍並嘗試它。讓我爲你更新它。 –