Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**********************************************************************************/
- /*How to create SERIVCE*/
- app.service('rest', function($http) {
- return {
- baseUrl: 'http://ec2-52-36-75-20.us-west-2.compute.amazonaws.com:3000/',
- path: undefined,
- login: function(loginData) {
- var url = this.baseUrl + this.path;
- return $http.post(url, loginData);
- }
- };
- });
- /**********************************************************************************/
- /**********************************************************************************/
- /* How to call rest Service from Controller*/
- //Call Service
- app.controller('loginCtrl', function($scope, $state, rest) {
- $scope.user = {
- 'email': '',
- 'password': ''
- };
- $scope.login = function() {
- rest.path = 'login';
- rest.login($scope.user).success(function(responseLoginData) {
- console.log(responseLoginData);
- });
- }
- });
- /**********************************************************************************/
Add Comment
Please, Sign In to add comment