After adding music I want to redirect on main page on cancel and save..
var app = angular.module("musicApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider.when("/Items", {
templateUrl: "view-list.html",
controller: "listController"
})
.when("/Items/add", {
templateUrl: "view-detail.html",
controller: "addController"
})
.when("/Items/:index", {
templateUrl: "view-detail.html",
controller: "editController"
})
.otherwise({
redirectTo: "/Items"
});
});
app.factory("productService", ["$rootScope", function($rootScope){
var service={};
var data = [{
name: "Artist1",
genre: "Genre1",
rating: "Rating1"
}, {
name: "Artist2",
genre: "Genre2",
rating: "Rating2"
}];
service.getProducts = function(){};
service.addProduct = function(product){};
service.editProduct = function(product){};
return service;
}]);
app.controller("listController", ["$scope", "$location", "$routeParams",
function($scope, $location, $routeParams) {
$scope
$scope.addProduct = function() {
$location.path("/Items/add");
};
$scope.editItem = function(index) {
$location.path("/Items/" + index);
};
}
]);
app.controller("addController", ["$scope", "$location", "$routeParams",
function($scope, $location, $routeParams) {
$scope.save = function() {
$location.url("/Items");
};
$scope.cancel = function() {
$location.path("/Items");
};
}
]);
app.controller("editController", ["$scope", "$location", "$routeParams",
function($scope, $location, $routeParams) {
$scope.save = function() {
$location.path("/Items");
};
$scope.cancel = function() {
$location.path("/Items");
};
}
]);
Main portion to go on main page is like:
app.controller("addController", ["$scope", "$location", "$routeParams",
function($scope, $location, $routeParams) {
$scope.save = function() {
$location.url("/Items");
};
$scope.cancel = function() {
$location.path("/Items");
};
}
]);
It does not redirect me to the main page where all my products are listed..
data-ng-model="item.name"and other model