Back Home see Bootstrap Notes

$scope.reconcile = function() {
		console.log("fired2..");
		submitBtn = true;
		 $http({method: 'GET', url: 'http://localhost:8090/jsonTest'}).
		 success(function(data, status, headers, config) {
		 // set view model or do something.
			 console.log("sucess result " + data.bssResult);
			 $scope.resultData = data.bssResult;			 
			 submitBtn = false;
 
		 }).
		 error(function(data, status, headers, config) {
			 console.log("failure");
			 submitBtn = true;
		 });
	};

Angular Services

  • $http - for non-restul ajax services
  • $resource - for addressing rest services

Angular Routes

If we are not using a single page application, Angular Routes can be used to route to the appropriate template

config(function ($routeProvider) {
    $routeProvider
      .when('/takenlijst', {
        templateUrl: 'views/takenlijst.html',
        controller: 'TakenlijstCtrl'
      })
      .when('/login', {
        templateUrl: 'views/login.html',
        controller: 'LoginCtrl'
      })
      .otherwise({
        redirectTo: '/takenlijst'
      });
  }).

Security

'use strict';
 
angular.module('jfall.Controllers')
    .controller('LoginCtrl', function ($scope, $rootScope, $location, $http) {
        $scope.user = {};
 
        $scope.login = function() {
            $scope.loginError = false;
            $http({
                method: 'post',
                //headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                url: '/api/login',
                data: $scope.user
            }).success(function() {
                $rootScope.loggedIn = true;
                $location.path('/');
            }).error(function() {
                $scope.loginError = true;
            });
        }
    });

Angular Modules

  • angular.module

Angular Json Parsing

 
angularjs.txt · Last modified: 2014/05/01 07:45 by root
 
RSS - 200 © CrosswireDigitialMedia Ltd