Robert Green Robert Green - 1 year ago 94
AngularJS Question

Angular Views Issue - Angular 1.5 - $stateProvider issue???- UI Router

I have a simple application which uses the $stateProvider to toggle between templates/views. I have two links:

<a href="#" ng-click="manage('area')">Areas</a>
<a href="#" ng-click="manage('vendors')">Vendors*</a>

I have the following handler in the controller:

var vm = $scope;

vm.manage = function (type) {

if (type == 'vendors') {
vm.message = 'Comming soon.';
} else {


When I click on the Areas link, I change the state to
(using the
call and then I see the template (and the html contents). Then, when I click the Vendors link I see the default message 'Comming soon'. Then when I click the Areas link again, I get the console.log from the area-controller but not the output (template and the html contents therein). What is going here, this is a very simple task that I do all the time and not sure why I'm not getting the static
the second time I request the

I have tried
and even
$scope = $
assuming somehow something in memory is clogged or something.

My module looks like this:

'use strict';
(function () {
angular.module('areaModule', []).config(areaModule);

areaModule.$inject = ['$stateProvider'];

function areaModule($stateProvider) {
.state('area', {
url: '/area',
templateUrl: 'app/assetManagement-app/modules/area/area.tmpl.html',
controller: 'area-controller'

and the controller looks like this

'use strict';
(function () {
angular.module('areaModule').controller('area-controller', areaController);

areaController.$inject = ['$scope', '$state', 'areaService'];

function areaController($scope, $state, areaService) {

var vm = $scope;

// clean up any memory leaks
$scope.$on('$destroy', function () { });

// init()
vm.init = function () {
console.log('area controller');


return vm;

and the template is here

<div class="container" style="margin: 10px 5px 10px 5px;">
<h1>Area Management View</h1>

What's going on?

Answer Source

It is a clash between href and state.go. If you remove href in your html It is working as expected.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download