I would like to use the $locationProvider
service in AngularJS without rendering a new HTML template in my ng-view
.
I have a div
element that is shown on demand via ng-show
binding to the existence of a data element. I would like to wire this to the browser location via the $locationProvider
but stay within the same template.
Template:
<div> other stuff ... </div>
<div ng-show="model">{{ model.element }}</div>
Controller:
Controller = function($scope, $location) {
$scope.show = function() {
$scope.model = model; // show div
}
$scope.hide = function() {
$scope.model = null; // hide div
}
}
I can't figure out how to integrate the $location
service in this. AngularJS also overwrites the location if it is set with history.pushState
directly.