AngularJS project to call RESTful service
Trying to modify an angularjs dashboard app angular-material-dashboard to use the RESTful ContactService.
This is a node.js program so requirements are:
Node.js / npm
$ cd project-directory $ npm install
Run web-server:
$ gulp serve
To Deploy
$ gulp build
This will create a dist/ directory with all the deliverables. Copy/FTP to your webserver.
Create src/app/controllers/ContactController.js
function ContactController($scope, $http) {
$http.get('https://your-project-id.appspot.com/contact/jsonlist.json').
success(function(data) {
$scope.contactData = data;
});
}
Problem occurs when trying to run program:
TypeError: Cannot read property 'get' of undefined
at new ContactController
Create src/app/components/services/ContactService.js
function contactService($q, $http){
$http.get('https://your-project-id.appspot.com/contact/jsonlist.json').
success(function(data) {
contactData = data;
});
Problem occurs when trying to run program:
TypeError: Cannot read property 'get' of undefined
at new contactService
Don’t know why the $http variable is not being injected.
Going to try to modify another angularjs project ang-starter.
Comments