javascript - Angularjs having multiple views with same controller and only run the controller once? -
right have 2 separate views want able controll in 1 controller.
however, @ moment, controller get's run twice. there anyway connect multiple views same controller have controller run once?
i know have set factory share $scope data, goal not gather data twice.
.state('cloud', { url: '/cloud', views: { 'main': { templateurl: 'main.html', controller: 'cloud' }, 'second': { templateurl: 'second.html', controller: 'cloud' } } })
the controller get's run twice because within "cloud" state defined 2 views , both views having same controller.
so, when both views gets loaded controller called twice.
but if want called controller once have defined separate controller both views.
Comments
Post a Comment