From 7a7745eeb28643818022f44a0ff45236873181f6 Mon Sep 17 00:00:00 2001 From: Konstantin Nikitin Date: Fri, 20 May 2016 16:30:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D1=8F=20=D0=BE=D0=BF=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=BD=D0=BE=D0=B9=20=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20=D0=BF=D0=BE=20=D0=B2=D0=BD?= =?UTF-8?q?=D0=B5=D1=88=D0=BD=D0=B5=D0=B9=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA?= =?UTF-8?q?=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- angular/app.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/angular/app.js b/angular/app.js index 28f0219..e4c80f9 100644 --- a/angular/app.js +++ b/angular/app.js @@ -11,13 +11,17 @@ app.run( ] ); -app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', +app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', function($stateProvider, $urlRouterProvider, $locationProvider) { + $urlRouterProvider.otherwise('/'); + $locationProvider.hashPrefix("!"); $stateProvider - .state('mainState', { + .state("home", { url: "", template: ''}) // начальное состояние. попали в него, значит перешли без цели + + .state("mainState", { url: "/{url}", templateUrl: "content.html", controller: ['$scope', '$http', '$sce', '$stateParams', function($scope, $http, $sce, $stateParams){ @@ -27,7 +31,7 @@ app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', $scope.fullContent = {}; $scope.sce = $sce; $scope.showContent = true; - + if ($stateParams.url === "/") { $scope.fullContent = {}; document.location.href='/'; @@ -47,6 +51,7 @@ app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', }] }) + }]); @@ -57,7 +62,10 @@ app.controller('mainMenu', [ '$http', '$state', function($http, $state) { mainMenu.listMenu = []; $http.get("/menu.json").success(function(data){ mainMenu.listMenu = data; - $state.go('mainState', {"url":mainMenu.listMenu[1].url}); + if ($state.$current.name == "home") { + $state.go('mainState', {"url":mainMenu.listMenu[1].url}); + } + }); }]);