How to set params in $http GET method to send data from dropdown Angularjs
I have a modal window for creating new object As you can see there three forms: 1) simple input to create "Name";
2) A dropdown with "Types" ;
3) A dropdown with "Ids";
I need to get data with types and Ids from DB, and as I can see in the browser and logs this part of process is going well, but when I fill all the forms and try to send them, there is always appears an Error, it happens because on server in variables "Types" and "IDs" written data from variable "Name", in short words it sent the data from input to all variables. This is a main question - why do it write data from input to all variables?? This is the html:
<tr>
<td class="collapsing">
<label>{{localization.common[locale].name}}</label>
</td>
<td>
<input type="text" placeholder="" ng-model="Name">
</td>
</tr>
<tr ng-controller="VirtualConnectorAddCtrl">
<td class="collapsing">
<label>{{localization.common[locale].VTypeID}}</label>
</td>
<td>
<select class="ui dropdown VTypeID" ng-model="VTypeID">
<option ng-repeat="item in virtualType" value= "'{{item.Id}}'">{{item.Name}}</option>
</select>
</td>
</tr>
<tr ng-controller="VirtualConnectorAddCtrl">
<td class="collapsing">
<label>{{localization.common[locale].account}}</label>
</td>
<td>
<select class="ui dropdown RunAsId" ng-model="RunAsId">
<option ng-repeat="list in runAccount" value= "'{{list.RunAsAccountId}}'">{{list.RunAsAccountName}}</option>
</select>
</td>
....
<div class="ui button blue" ng-click="createData(modal_id, Name, VTypeID, RunAsId)">{{localization.common[locale].add}}</div>
I had the same problem with creating "Account"(you can see on the image on left side menu: VirtualTypes, Account, VirtualConnectors), and there the issue was about $http params in controller
$scope.createData = function (obj, data, extra) {
....
if ($scope.dictFilter == 'accounts') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_RunAsAccount',
params: { name: data, pasword: data}
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
});
return;
} ....
When I replace 'password:data' to 'password:extra' the problem was solved, but with "VirtualConnectors" I couldn't find the way to do this (all creating processes are initializes by function "createData", and I am trying to add new block to that function)
if ($scope.dictFilter == 'virtualConnectors') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_VirtualConnector',
params: {name: data, VtypeID: data, RunAsID:data }
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
console.log("function createData doesn't callback");
});
return;
}
maybe it's about params, in this case there three of them (actually 4, including obj "modal"), but function acccept only 2 arguments (actually 3 -including "obj"), the function works for other cases, and in other cases params do not always fit to arguments... In internet not much information about "params", so I can't understand the logic of binding html and controller here. Obviously, in html-file function CreateData take "modal_id", "Name", "VtypeID" and "RunAsId" as arguments so in the controller this function should be set with arguments that can take such types of data (obj, string, string, string), but there is (obj, data, extra), I've tried to change function arguments in the controller: $scope.createData = function (obj, data, extra, string) {...
and it doesn't help... I think I should write another function for this case, but what arguments should I put? And one more thing: is it right to use form with options created by ng-repeat for such case (when I need to send a string that is a property of an object)?
javascript html angularjs html5
add a comment |
I have a modal window for creating new object As you can see there three forms: 1) simple input to create "Name";
2) A dropdown with "Types" ;
3) A dropdown with "Ids";
I need to get data with types and Ids from DB, and as I can see in the browser and logs this part of process is going well, but when I fill all the forms and try to send them, there is always appears an Error, it happens because on server in variables "Types" and "IDs" written data from variable "Name", in short words it sent the data from input to all variables. This is a main question - why do it write data from input to all variables?? This is the html:
<tr>
<td class="collapsing">
<label>{{localization.common[locale].name}}</label>
</td>
<td>
<input type="text" placeholder="" ng-model="Name">
</td>
</tr>
<tr ng-controller="VirtualConnectorAddCtrl">
<td class="collapsing">
<label>{{localization.common[locale].VTypeID}}</label>
</td>
<td>
<select class="ui dropdown VTypeID" ng-model="VTypeID">
<option ng-repeat="item in virtualType" value= "'{{item.Id}}'">{{item.Name}}</option>
</select>
</td>
</tr>
<tr ng-controller="VirtualConnectorAddCtrl">
<td class="collapsing">
<label>{{localization.common[locale].account}}</label>
</td>
<td>
<select class="ui dropdown RunAsId" ng-model="RunAsId">
<option ng-repeat="list in runAccount" value= "'{{list.RunAsAccountId}}'">{{list.RunAsAccountName}}</option>
</select>
</td>
....
<div class="ui button blue" ng-click="createData(modal_id, Name, VTypeID, RunAsId)">{{localization.common[locale].add}}</div>
I had the same problem with creating "Account"(you can see on the image on left side menu: VirtualTypes, Account, VirtualConnectors), and there the issue was about $http params in controller
$scope.createData = function (obj, data, extra) {
....
if ($scope.dictFilter == 'accounts') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_RunAsAccount',
params: { name: data, pasword: data}
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
});
return;
} ....
When I replace 'password:data' to 'password:extra' the problem was solved, but with "VirtualConnectors" I couldn't find the way to do this (all creating processes are initializes by function "createData", and I am trying to add new block to that function)
if ($scope.dictFilter == 'virtualConnectors') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_VirtualConnector',
params: {name: data, VtypeID: data, RunAsID:data }
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
console.log("function createData doesn't callback");
});
return;
}
maybe it's about params, in this case there three of them (actually 4, including obj "modal"), but function acccept only 2 arguments (actually 3 -including "obj"), the function works for other cases, and in other cases params do not always fit to arguments... In internet not much information about "params", so I can't understand the logic of binding html and controller here. Obviously, in html-file function CreateData take "modal_id", "Name", "VtypeID" and "RunAsId" as arguments so in the controller this function should be set with arguments that can take such types of data (obj, string, string, string), but there is (obj, data, extra), I've tried to change function arguments in the controller: $scope.createData = function (obj, data, extra, string) {...
and it doesn't help... I think I should write another function for this case, but what arguments should I put? And one more thing: is it right to use form with options created by ng-repeat for such case (when I need to send a string that is a property of an object)?
javascript html angularjs html5
1
Hey Dasha, I am not able to understand what's the actual question. Can you please correct the sentence and be more clear about your question. That being said, I can seeng-click="createData(modal_id, Name, VTypeID, RunAsId)"
has 4 params where as in yourjs
file$scope.createData = function (obj, data, extra) {
is only able to handle 3 arguments. Please check if that's not the issue and let me know :)
– Shashank Vivek
Nov 14 '18 at 16:43
Shashank Vivek, thank you for answer. You are right, of course, but how should I fix it? I'm sorry if it's hard to understand my explanation, english is not my first language. I've added a picture, and rewrited the question.
– Dasha Custo
Nov 15 '18 at 11:22
Did my answer helped ?
– Shashank Vivek
Nov 20 '18 at 16:52
Sorry, but no =(
– Dasha Custo
Nov 21 '18 at 7:36
Sorry, but no =( when I call the function in html it nust have 4 params (with modal_id) because modal_id tell to the function what condition to take (the function is structured by "if"-blocks, and without modal_id function doesn't knoe what block to produce, so it shows log "data undefined"). Also I shouldn't put modal_id to the arguments (I've tried, it brings error). Your advice seems very logical to me, but it doesnt work. This app was created by another man, and I just trying to follow his logic, everything works, and this function working perfectly, I just need to understand this logic
– Dasha Custo
Nov 21 '18 at 7:51
add a comment |
I have a modal window for creating new object As you can see there three forms: 1) simple input to create "Name";
2) A dropdown with "Types" ;
3) A dropdown with "Ids";
I need to get data with types and Ids from DB, and as I can see in the browser and logs this part of process is going well, but when I fill all the forms and try to send them, there is always appears an Error, it happens because on server in variables "Types" and "IDs" written data from variable "Name", in short words it sent the data from input to all variables. This is a main question - why do it write data from input to all variables?? This is the html:
<tr>
<td class="collapsing">
<label>{{localization.common[locale].name}}</label>
</td>
<td>
<input type="text" placeholder="" ng-model="Name">
</td>
</tr>
<tr ng-controller="VirtualConnectorAddCtrl">
<td class="collapsing">
<label>{{localization.common[locale].VTypeID}}</label>
</td>
<td>
<select class="ui dropdown VTypeID" ng-model="VTypeID">
<option ng-repeat="item in virtualType" value= "'{{item.Id}}'">{{item.Name}}</option>
</select>
</td>
</tr>
<tr ng-controller="VirtualConnectorAddCtrl">
<td class="collapsing">
<label>{{localization.common[locale].account}}</label>
</td>
<td>
<select class="ui dropdown RunAsId" ng-model="RunAsId">
<option ng-repeat="list in runAccount" value= "'{{list.RunAsAccountId}}'">{{list.RunAsAccountName}}</option>
</select>
</td>
....
<div class="ui button blue" ng-click="createData(modal_id, Name, VTypeID, RunAsId)">{{localization.common[locale].add}}</div>
I had the same problem with creating "Account"(you can see on the image on left side menu: VirtualTypes, Account, VirtualConnectors), and there the issue was about $http params in controller
$scope.createData = function (obj, data, extra) {
....
if ($scope.dictFilter == 'accounts') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_RunAsAccount',
params: { name: data, pasword: data}
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
});
return;
} ....
When I replace 'password:data' to 'password:extra' the problem was solved, but with "VirtualConnectors" I couldn't find the way to do this (all creating processes are initializes by function "createData", and I am trying to add new block to that function)
if ($scope.dictFilter == 'virtualConnectors') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_VirtualConnector',
params: {name: data, VtypeID: data, RunAsID:data }
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
console.log("function createData doesn't callback");
});
return;
}
maybe it's about params, in this case there three of them (actually 4, including obj "modal"), but function acccept only 2 arguments (actually 3 -including "obj"), the function works for other cases, and in other cases params do not always fit to arguments... In internet not much information about "params", so I can't understand the logic of binding html and controller here. Obviously, in html-file function CreateData take "modal_id", "Name", "VtypeID" and "RunAsId" as arguments so in the controller this function should be set with arguments that can take such types of data (obj, string, string, string), but there is (obj, data, extra), I've tried to change function arguments in the controller: $scope.createData = function (obj, data, extra, string) {...
and it doesn't help... I think I should write another function for this case, but what arguments should I put? And one more thing: is it right to use form with options created by ng-repeat for such case (when I need to send a string that is a property of an object)?
javascript html angularjs html5
I have a modal window for creating new object As you can see there three forms: 1) simple input to create "Name";
2) A dropdown with "Types" ;
3) A dropdown with "Ids";
I need to get data with types and Ids from DB, and as I can see in the browser and logs this part of process is going well, but when I fill all the forms and try to send them, there is always appears an Error, it happens because on server in variables "Types" and "IDs" written data from variable "Name", in short words it sent the data from input to all variables. This is a main question - why do it write data from input to all variables?? This is the html:
<tr>
<td class="collapsing">
<label>{{localization.common[locale].name}}</label>
</td>
<td>
<input type="text" placeholder="" ng-model="Name">
</td>
</tr>
<tr ng-controller="VirtualConnectorAddCtrl">
<td class="collapsing">
<label>{{localization.common[locale].VTypeID}}</label>
</td>
<td>
<select class="ui dropdown VTypeID" ng-model="VTypeID">
<option ng-repeat="item in virtualType" value= "'{{item.Id}}'">{{item.Name}}</option>
</select>
</td>
</tr>
<tr ng-controller="VirtualConnectorAddCtrl">
<td class="collapsing">
<label>{{localization.common[locale].account}}</label>
</td>
<td>
<select class="ui dropdown RunAsId" ng-model="RunAsId">
<option ng-repeat="list in runAccount" value= "'{{list.RunAsAccountId}}'">{{list.RunAsAccountName}}</option>
</select>
</td>
....
<div class="ui button blue" ng-click="createData(modal_id, Name, VTypeID, RunAsId)">{{localization.common[locale].add}}</div>
I had the same problem with creating "Account"(you can see on the image on left side menu: VirtualTypes, Account, VirtualConnectors), and there the issue was about $http params in controller
$scope.createData = function (obj, data, extra) {
....
if ($scope.dictFilter == 'accounts') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_RunAsAccount',
params: { name: data, pasword: data}
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
});
return;
} ....
When I replace 'password:data' to 'password:extra' the problem was solved, but with "VirtualConnectors" I couldn't find the way to do this (all creating processes are initializes by function "createData", and I am trying to add new block to that function)
if ($scope.dictFilter == 'virtualConnectors') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_VirtualConnector',
params: {name: data, VtypeID: data, RunAsID:data }
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
console.log("function createData doesn't callback");
});
return;
}
maybe it's about params, in this case there three of them (actually 4, including obj "modal"), but function acccept only 2 arguments (actually 3 -including "obj"), the function works for other cases, and in other cases params do not always fit to arguments... In internet not much information about "params", so I can't understand the logic of binding html and controller here. Obviously, in html-file function CreateData take "modal_id", "Name", "VtypeID" and "RunAsId" as arguments so in the controller this function should be set with arguments that can take such types of data (obj, string, string, string), but there is (obj, data, extra), I've tried to change function arguments in the controller: $scope.createData = function (obj, data, extra, string) {...
and it doesn't help... I think I should write another function for this case, but what arguments should I put? And one more thing: is it right to use form with options created by ng-repeat for such case (when I need to send a string that is a property of an object)?
javascript html angularjs html5
javascript html angularjs html5
edited Nov 15 '18 at 17:16
asked Nov 14 '18 at 16:15
Dasha Custo
214
214
1
Hey Dasha, I am not able to understand what's the actual question. Can you please correct the sentence and be more clear about your question. That being said, I can seeng-click="createData(modal_id, Name, VTypeID, RunAsId)"
has 4 params where as in yourjs
file$scope.createData = function (obj, data, extra) {
is only able to handle 3 arguments. Please check if that's not the issue and let me know :)
– Shashank Vivek
Nov 14 '18 at 16:43
Shashank Vivek, thank you for answer. You are right, of course, but how should I fix it? I'm sorry if it's hard to understand my explanation, english is not my first language. I've added a picture, and rewrited the question.
– Dasha Custo
Nov 15 '18 at 11:22
Did my answer helped ?
– Shashank Vivek
Nov 20 '18 at 16:52
Sorry, but no =(
– Dasha Custo
Nov 21 '18 at 7:36
Sorry, but no =( when I call the function in html it nust have 4 params (with modal_id) because modal_id tell to the function what condition to take (the function is structured by "if"-blocks, and without modal_id function doesn't knoe what block to produce, so it shows log "data undefined"). Also I shouldn't put modal_id to the arguments (I've tried, it brings error). Your advice seems very logical to me, but it doesnt work. This app was created by another man, and I just trying to follow his logic, everything works, and this function working perfectly, I just need to understand this logic
– Dasha Custo
Nov 21 '18 at 7:51
add a comment |
1
Hey Dasha, I am not able to understand what's the actual question. Can you please correct the sentence and be more clear about your question. That being said, I can seeng-click="createData(modal_id, Name, VTypeID, RunAsId)"
has 4 params where as in yourjs
file$scope.createData = function (obj, data, extra) {
is only able to handle 3 arguments. Please check if that's not the issue and let me know :)
– Shashank Vivek
Nov 14 '18 at 16:43
Shashank Vivek, thank you for answer. You are right, of course, but how should I fix it? I'm sorry if it's hard to understand my explanation, english is not my first language. I've added a picture, and rewrited the question.
– Dasha Custo
Nov 15 '18 at 11:22
Did my answer helped ?
– Shashank Vivek
Nov 20 '18 at 16:52
Sorry, but no =(
– Dasha Custo
Nov 21 '18 at 7:36
Sorry, but no =( when I call the function in html it nust have 4 params (with modal_id) because modal_id tell to the function what condition to take (the function is structured by "if"-blocks, and without modal_id function doesn't knoe what block to produce, so it shows log "data undefined"). Also I shouldn't put modal_id to the arguments (I've tried, it brings error). Your advice seems very logical to me, but it doesnt work. This app was created by another man, and I just trying to follow his logic, everything works, and this function working perfectly, I just need to understand this logic
– Dasha Custo
Nov 21 '18 at 7:51
1
1
Hey Dasha, I am not able to understand what's the actual question. Can you please correct the sentence and be more clear about your question. That being said, I can see
ng-click="createData(modal_id, Name, VTypeID, RunAsId)"
has 4 params where as in your js
file $scope.createData = function (obj, data, extra) {
is only able to handle 3 arguments. Please check if that's not the issue and let me know :)– Shashank Vivek
Nov 14 '18 at 16:43
Hey Dasha, I am not able to understand what's the actual question. Can you please correct the sentence and be more clear about your question. That being said, I can see
ng-click="createData(modal_id, Name, VTypeID, RunAsId)"
has 4 params where as in your js
file $scope.createData = function (obj, data, extra) {
is only able to handle 3 arguments. Please check if that's not the issue and let me know :)– Shashank Vivek
Nov 14 '18 at 16:43
Shashank Vivek, thank you for answer. You are right, of course, but how should I fix it? I'm sorry if it's hard to understand my explanation, english is not my first language. I've added a picture, and rewrited the question.
– Dasha Custo
Nov 15 '18 at 11:22
Shashank Vivek, thank you for answer. You are right, of course, but how should I fix it? I'm sorry if it's hard to understand my explanation, english is not my first language. I've added a picture, and rewrited the question.
– Dasha Custo
Nov 15 '18 at 11:22
Did my answer helped ?
– Shashank Vivek
Nov 20 '18 at 16:52
Did my answer helped ?
– Shashank Vivek
Nov 20 '18 at 16:52
Sorry, but no =(
– Dasha Custo
Nov 21 '18 at 7:36
Sorry, but no =(
– Dasha Custo
Nov 21 '18 at 7:36
Sorry, but no =( when I call the function in html it nust have 4 params (with modal_id) because modal_id tell to the function what condition to take (the function is structured by "if"-blocks, and without modal_id function doesn't knoe what block to produce, so it shows log "data undefined"). Also I shouldn't put modal_id to the arguments (I've tried, it brings error). Your advice seems very logical to me, but it doesnt work. This app was created by another man, and I just trying to follow his logic, everything works, and this function working perfectly, I just need to understand this logic
– Dasha Custo
Nov 21 '18 at 7:51
Sorry, but no =( when I call the function in html it nust have 4 params (with modal_id) because modal_id tell to the function what condition to take (the function is structured by "if"-blocks, and without modal_id function doesn't knoe what block to produce, so it shows log "data undefined"). Also I shouldn't put modal_id to the arguments (I've tried, it brings error). Your advice seems very logical to me, but it doesnt work. This app was created by another man, and I just trying to follow his logic, everything works, and this function working perfectly, I just need to understand this logic
– Dasha Custo
Nov 21 '18 at 7:51
add a comment |
1 Answer
1
active
oldest
votes
why do it write data from input to all variables?
Because, you are assigning data
to all properties
params: {name: data, VtypeID: data, RunAsID:data }
you should do,
$scope.createData = function (modal_id, name, vTypeID, runAsId) {
and then:
if ($scope.dictFilter == 'virtualConnectors') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_VirtualConnector',
params: {name: name, VtypeID: vTypeID, RunAsID: runAsId } // <-- Check this line
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
console.log("function createData doesn't callback");
});
return;
}
similarly, correct the params
for 'accounts
'.
There are several bad practices in your code as well:
- using
ng-controller
on each<tr>
tag. Use it on table level - Passing
modal_id
when it's not being used. - passing
name
in your casedata
as password. It doesn't make any sense to name variable incorrectly. IF its aname
, you shouldn't use password to refer it.
I will suggest you to get your code reviewed by some expert to avoid "bad coding practices" that you are following in your code.
I hope my answer will help you :)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304525%2fhow-to-set-params-in-http-get-method-to-send-data-from-dropdown-angularjs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
why do it write data from input to all variables?
Because, you are assigning data
to all properties
params: {name: data, VtypeID: data, RunAsID:data }
you should do,
$scope.createData = function (modal_id, name, vTypeID, runAsId) {
and then:
if ($scope.dictFilter == 'virtualConnectors') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_VirtualConnector',
params: {name: name, VtypeID: vTypeID, RunAsID: runAsId } // <-- Check this line
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
console.log("function createData doesn't callback");
});
return;
}
similarly, correct the params
for 'accounts
'.
There are several bad practices in your code as well:
- using
ng-controller
on each<tr>
tag. Use it on table level - Passing
modal_id
when it's not being used. - passing
name
in your casedata
as password. It doesn't make any sense to name variable incorrectly. IF its aname
, you shouldn't use password to refer it.
I will suggest you to get your code reviewed by some expert to avoid "bad coding practices" that you are following in your code.
I hope my answer will help you :)
add a comment |
why do it write data from input to all variables?
Because, you are assigning data
to all properties
params: {name: data, VtypeID: data, RunAsID:data }
you should do,
$scope.createData = function (modal_id, name, vTypeID, runAsId) {
and then:
if ($scope.dictFilter == 'virtualConnectors') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_VirtualConnector',
params: {name: name, VtypeID: vTypeID, RunAsID: runAsId } // <-- Check this line
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
console.log("function createData doesn't callback");
});
return;
}
similarly, correct the params
for 'accounts
'.
There are several bad practices in your code as well:
- using
ng-controller
on each<tr>
tag. Use it on table level - Passing
modal_id
when it's not being used. - passing
name
in your casedata
as password. It doesn't make any sense to name variable incorrectly. IF its aname
, you shouldn't use password to refer it.
I will suggest you to get your code reviewed by some expert to avoid "bad coding practices" that you are following in your code.
I hope my answer will help you :)
add a comment |
why do it write data from input to all variables?
Because, you are assigning data
to all properties
params: {name: data, VtypeID: data, RunAsID:data }
you should do,
$scope.createData = function (modal_id, name, vTypeID, runAsId) {
and then:
if ($scope.dictFilter == 'virtualConnectors') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_VirtualConnector',
params: {name: name, VtypeID: vTypeID, RunAsID: runAsId } // <-- Check this line
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
console.log("function createData doesn't callback");
});
return;
}
similarly, correct the params
for 'accounts
'.
There are several bad practices in your code as well:
- using
ng-controller
on each<tr>
tag. Use it on table level - Passing
modal_id
when it's not being used. - passing
name
in your casedata
as password. It doesn't make any sense to name variable incorrectly. IF its aname
, you shouldn't use password to refer it.
I will suggest you to get your code reviewed by some expert to avoid "bad coding practices" that you are following in your code.
I hope my answer will help you :)
why do it write data from input to all variables?
Because, you are assigning data
to all properties
params: {name: data, VtypeID: data, RunAsID:data }
you should do,
$scope.createData = function (modal_id, name, vTypeID, runAsId) {
and then:
if ($scope.dictFilter == 'virtualConnectors') {
$http({
method: 'GET',
url: appID + '/Insert_Methods.asmx/Insert_VirtualConnector',
params: {name: name, VtypeID: vTypeID, RunAsID: runAsId } // <-- Check this line
}).then(function successCallback(response) {
Modals.close(obj)
getData();
}, function errorCallback(response) {
console.log("function createData doesn't callback");
});
return;
}
similarly, correct the params
for 'accounts
'.
There are several bad practices in your code as well:
- using
ng-controller
on each<tr>
tag. Use it on table level - Passing
modal_id
when it's not being used. - passing
name
in your casedata
as password. It doesn't make any sense to name variable incorrectly. IF its aname
, you shouldn't use password to refer it.
I will suggest you to get your code reviewed by some expert to avoid "bad coding practices" that you are following in your code.
I hope my answer will help you :)
answered Nov 17 '18 at 8:12
Shashank Vivek
4,15232356
4,15232356
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304525%2fhow-to-set-params-in-http-get-method-to-send-data-from-dropdown-angularjs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Hey Dasha, I am not able to understand what's the actual question. Can you please correct the sentence and be more clear about your question. That being said, I can see
ng-click="createData(modal_id, Name, VTypeID, RunAsId)"
has 4 params where as in yourjs
file$scope.createData = function (obj, data, extra) {
is only able to handle 3 arguments. Please check if that's not the issue and let me know :)– Shashank Vivek
Nov 14 '18 at 16:43
Shashank Vivek, thank you for answer. You are right, of course, but how should I fix it? I'm sorry if it's hard to understand my explanation, english is not my first language. I've added a picture, and rewrited the question.
– Dasha Custo
Nov 15 '18 at 11:22
Did my answer helped ?
– Shashank Vivek
Nov 20 '18 at 16:52
Sorry, but no =(
– Dasha Custo
Nov 21 '18 at 7:36
Sorry, but no =( when I call the function in html it nust have 4 params (with modal_id) because modal_id tell to the function what condition to take (the function is structured by "if"-blocks, and without modal_id function doesn't knoe what block to produce, so it shows log "data undefined"). Also I shouldn't put modal_id to the arguments (I've tried, it brings error). Your advice seems very logical to me, but it doesnt work. This app was created by another man, and I just trying to follow his logic, everything works, and this function working perfectly, I just need to understand this logic
– Dasha Custo
Nov 21 '18 at 7:51