如果是角度JS,如何处理if [英] How to handle if else in case of angular JS
本文介绍了如果是角度JS,如何处理if的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网址,我从中检索状态相关数据,但我想为所有状态执行此操作。我从我的html传递状态作为参数但是无法这样做。
请建议怎么做。它仅适用于一个州。
我尝试过:
我试过以下
my.js
-------
I have a url from which I am retrieving state related data but I want to do it for all states. I am passing state as an argument from my html but unable to do so.
Please suggest how to do it. It is working for only one states.
What I have tried:
I have tried following
my.js
-------
var myapp = angular.module('myApp', []);
myapp.controller("HttpPostController", function ($scope, $http) {
$scope.SendHttpPostData = function () {
var data = $.param({
stnm: $scope.stateName,
});
var statename = document.getElementById("stnm").value;
var config = {
headers : {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
}
}
if(statename==='AP') //here I want to handle for all states using else if condition.
$http.get('https://myurl', data, config)
.success(function (data, status, headers, config) {
$scope.ServerResponse = data.records;
})
.error(function (data, status, header, config) {
});
};
});
我想基于我应该处理的所有状态来处理。
I want to handle based on my input it should handle for all states.
推荐答案
范围,
http){
scope.SendHttpPostData = 函数(){
var data =
scope.SendHttpPostData = function () { var data =
这篇关于如果是角度JS,如何处理if的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文