0

I am experienced in ASP.NET and web/database applications; I am learning and trying out Angular. I found a very good database example at w3schools.com, here:

http://www.w3schools.com/angular/angular_sql.asp

(see sections "Fetching Data From an ASP.NET Server Running SQL" and "4. Server Code ASP.NET, VB Razor and SQL Lite").

The Angular code is just:

$http.get("http://www.w3schools.com/angular/customers_sql.aspx")

and the sample query in the aspx page is:

"SELECT CompanyName, City, Country FROM Customers"

My problem is, there is no explanation of how to pass parameters to a query similar to this:

"SELECT CompanyName, City, Country FROM Customers Where Country = " & txtSomething

I know how to change the aspx page to read parameters on the ASP.NET side, but I don't know how to pass them from the Angular code.

How should I modify this Angular code to pass parameters to the aspx page?

var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
    $http.get("http://www.w3schools.com/angular/customers_sql.aspx")
    .success(function (response) {$scope.names = response.records;});
});

Thank you.

2

2 Answers 2

1

You can add a query string to the request.

angular.http provides an option for it params.

$http({ url: "http://www.w3schools.com/angular/customers_sql.aspx", method: "GET", params: {id: someId} });

Sign up to request clarification or add additional context in comments.

Comments

0

Your easiest option is probably to add query string parameters:

"htp://www.w3schools.com/angular/customers_sql.aspx?country=" + $scope.country

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.