javascript - URL changes for a millisecond and comes back to original.$location.url not working (Angular JS) -
here code angular app. in $scope.$on('promotion_create) event handler, trying change url , render partials .but url changes few milisecond , comes without rendering .
(function (angular){ var app = angular.module('promotionsdashboard',[]); app.config(['$routeprovider', function($routeprovider) { $routeprovider. when('/', {templateurl: 'promotions/routes/dashboard/promotions-home', controller:'promotionshomecontroller' }). when('/create/', {templateurl: 'promotions/routes/dashboard/create-promotions', controller: 'createpromotionscontroller'}). otherwise({redirectto: '/'}); }]); app.controller('promotionshomecontroller', ['$scope', '$rootscope','$location', function($scope, $rootscope,$location){ $scope.createpromotion = function(){ console.log("hello"); $rootscope.$broadcast('promotion_create'); }; $scope.$on('promotion_create', function(){ $location.url('/create/'); //this call not work }); $scope.test="hello"; }]); app.controller('createpromotionscontroller', ['$scope', '$routeparams', '$location', function($scope, $routeparams, $location){ $scope.query = $routeparams.query; $scope.search = function(){ if($scope.query){ $location.path('/create/' + $scope.query); } }; } ]); })(angular);
my html file follows
<div ng-controller="promotionshomecontroller" class="ng-scope"> <div>this home page.this yet implemented</div> <a ng-click="createpromotion()" href="#" class="ng-binding">create promotions hello</a>
`
i checked create-promotion partial file being fetched server not being rendered . can please point out going wrong ?
Comments
Post a Comment