Consider angular routing as below.
1 2 3 4 5 6 7 8 9 |
app.config(function ($routeProvider, $locationProvider, $httpProvider) { $routeProvider.when('/createproduct', { // controller: 'adminController', templateUrl: '/Scripts/app/admin/partial/CreateProduct.html', title: 'Create Product', instancename: 'createproduct' }) }); |
and just need to write code as below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
var instancename = ''; app.run(['$rootScope', '$location', '$timeout', '$mdSidenav', function ($rootScope, $location, $timeout, $mdSidenav) { $rootScope.$on('$routeChangeSuccess', function (event, current, previous) { $rootScope.title = current.$$route.title; var d = current.$$route.current; instancename = current.$$route.instancename; }); function mdSidenavOpen(instancename) { $mdSidenav(instancename).open(); } $rootScope.$on('$viewContentLoaded', function () { if (instancename != undefined && instancename != '') { $timeout(mdSidenavOpen(instancename), 200); } }); }]); |
and in the html side, just need to add below code on the layout/common page.
1 |
<title ng-bind="title"></title> |