var AddCtrl = function($scope, $stateParams, $http, Revision, Article, $location) {
$scope.create = function() {
if ($scope.article) {
$scope.revision={};
Article.create($scope.article, function(data, headers){
angular.copy($scope.article, $scope.revision);
$scope.revision.article_id = data.id;
$scope.revision.content = data.content;
$scope.revision.title = data.title;
Revision.create($scope.revision);
$location.path('#/wiki/revision/'+$scope.revision.article_id);
});
}
if ($scope.revision && $stateParams.id) {
$scope.revision.article_id = $stateParams.id;
Revision.create($scope.revision);
}
};
};
This is what my controller for adding a post looks like and I'd like to redirect the person to the newly created post. Trouble is - $location.path redirects me to #/home (index page) every time I try this.
I have tried putting in hard coded links and that didn't work out either. What is wrong with my code and what can I do to mend it?
#.