1
Nach Hinzufügen von Musik ich auf Abbrechen und speichern auf der Hauptseite umleiten möchten ..Redirect auf Seite auf die Schaltfläche klicken in Winkel js
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");
};
}
]);
Hauptteil auf der Hauptseite zu gehen ist wie:
app.controller("addController", ["$scope", "$location", "$routeParams",
function($scope, $location, $routeParams) {
$scope.save = function() {
$location.url("/Items");
};
$scope.cancel = function() {
$location.path("/Items");
};
}
]);
Es macht mich nicht auf die Hauptseite umgeleitet, wo alle meine Produkte aufgeführt sind ..
Haben Sie eine Geige für Ihre Anwendung oder Link haben? – Khaleel
ja @Khaleel https://plnrkr.co/edit/tMAUSbCR4sXga9ilnmMe?p=preview bitte überprüfen Sie diese – Dhara
Sie haben einen Fehler in Ihrem "View-Detail.html". Sie haben vergessen, doppelte Anführungszeichen in 'data-ng-model =" item.name "' und andere Modell – pryxen