how to get params using angularjs

June 06, 2015

Reading time ~1 minute

Basic Usage

If you want to get params using angularjs

app.js

angular.module('app', [])
 .config(appConfig);

appConfig.$inject = ['$routeProvider'];

function appConfig($routeProvider){
  $routeProvider.when('/item', {
    templateUrl: 'xxxxx.html',
    controller : 'ItemController'
  });
}

itemController.js

angular.module('app')
  .controller('ItemController', ItemController);

ItemController.$inject = ['$routeParams'];

function ItemController($routeParams){
  // you can get params
  // url : http://example.com?page=1
  var page = $routeParams.page; // page = 1
}

Usage for No SAP page

If you do not need to create SAP page you can get params like this.

app.js

angular.module('app', [])

appConfig.$inject = ['$locationProvider'];

function appConfig($locationProvider){
  $locationProvider.html5Mode({enable: true, requireBase: false, rewriteLinks: false});
}

itemController.js

angular.module('app')
  .controller('ItemController', ItemController);

ItemController.$inject = ['$routeParams'];

function ItemController($routeParams){
  // you can get params
  // url : http://example.com?page=1
  var page = $routeParams.page; // page = 1
}

add ticket number to git commit automatically

Most of ticket tracker like Github, pivotal tracker have function to connect your commit to ticket(story).But every time when you commit ...… Continue reading

I will build frontend and backend separately

Published on September 28, 2016

order of angular controller's initialisation

Published on October 05, 2015