Dinesh Kumar
asked on
Angular Question
Experts!
I am learning Angular and trying to get products from the database, the products in the following link are coming as static from store.js file.
http://www.codeproject.com/Articles/576246/A-Shopping-Cart-Application-Built-with-AngularJS
What is the way of doing it.
I am trying the following code, but I don't see any error or any success. Could you please help me.
(
function () {
var app = angular.module("productVie wer", []);
var ProductController = function ($scope, $http) {
var onUserComplete = function (response) {
alert(response.data);
$scope.products = response.data;
};
var onError = function (reason) {
alert("error");
$scope.error = "Could not fetch the Products";
};
$http.get("https://api.github.com/users/robconery")
.then(onUserComplete, onError);
};
app.controller(
"ProductController", ["$scope", "$http", ProductController]);
}());
Thanks
Dinesh Kumar
Please Note: I wanted to make change in the existing code given on the code project article mentioned earlier.
I am learning Angular and trying to get products from the database, the products in the following link are coming as static from store.js file.
http://www.codeproject.com/Articles/576246/A-Shopping-Cart-Application-Built-with-AngularJS
What is the way of doing it.
I am trying the following code, but I don't see any error or any success. Could you please help me.
(
function () {
var app = angular.module("productVie
var ProductController = function ($scope, $http) {
var onUserComplete = function (response) {
alert(response.data);
$scope.products = response.data;
};
var onError = function (reason) {
alert("error");
$scope.error = "Could not fetch the Products";
};
$http.get("https://api.github.com/users/robconery")
.then(onUserComplete, onError);
};
app.controller(
"ProductController", ["$scope", "$http", ProductController]);
}());
Thanks
Dinesh Kumar
Please Note: I wanted to make change in the existing code given on the code project article mentioned earlier.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you are still writing function expressions. why?
why are you rewriting the tutorial?
If you want to learn angular, you have to learn the fundamentals of javascript first.
function declarations vs function expressions is just one of those fundamentals.
why are you rewriting the tutorial?
If you want to learn angular, you have to learn the fundamentals of javascript first.
function declarations vs function expressions is just one of those fundamentals.
ASKER
Thank you Kyle!
np :)
ASKER
Open in new window
And in the store.js file, I am trying further code with some modification:
function store(ProductService) {
this.products = ProductService.getAllProdu
alert(this.products);
but it says getAllProducts is undefined. :(