1
添加音樂後,我想在取消和節省主頁上的重定向按鈕點擊網頁..重定向到對角的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");
};
}
]);
主要部分去主頁上是這樣的:
app.controller("addController", ["$scope", "$location", "$routeParams",
function($scope, $location, $routeParams) {
$scope.save = function() {
$location.url("/Items");
};
$scope.cancel = function() {
$location.path("/Items");
};
}
]);
它不重定向我在我的所有產品都列在主網頁..
你對你的應用程序或鏈接小提琴? – Khaleel
是@Khaleel https://plnkr.co/edit/tMAUSbCR4sXga9ilnmMe?p=preview請查看 – Dhara
您在「view-detail.html」中看到錯誤。你忘了把雙引號放在'data-ng-model =「item.name」'和其他型號 – pryxen