Angular.js change ng-click location
I've read some other posts on the same topic, but can't seem to get myself to work. Basically, I want the location of my app to change to an ng-click event. So I have html code that looks like this:
<button class="button icon-left ion-plus-round button-block button-calm" ng-click="send({{foods.cal}})">
Add Calories
</button>
And a controller that looks like this:
.controller('foodDetailCtrl', function($scope, $stateParams, $location, foods) {
$scope.foods = foods.get($stateParams.foodsId);
$scope.send = function(i) {
// do something with 'i'
$location.path('/calc');
}
})
But when I click on my html button, the location is updated on the home tab as if it can't find "/ calc". I tried calc preceeded by parent folders and followed by file extension but couldn't get this to work. Any help was massively appreciated.
+3
source to share
2 answers
Try the following:
app.config(function($routeProvider) {
$locationProvider.html5Mode(true);
});
And try adding a base tag to your html header. http://www.w3schools.com/tags/tag_base.asp
0
source to share