午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術(shù)文章
文章詳情頁

javascript - 請(qǐng)教AngularJS的ngRoute問題:為何這段程序無法執(zhí)行?問題出在哪?

瀏覽:200日期:2022-12-20 16:28:02

問題描述

/** index.html **/<!DOCTYPE html><html ng-app='exampleApp'><head> <title>Products</title> <script src='http://www.leifengta.com.cn/wenda/angular.js'></script> <script src='http://www.leifengta.com.cn/wenda/angular-route.js'></script> <script src='http://www.leifengta.com.cn/wenda/products.js'></script> <link href='http://www.leifengta.com.cn/wenda/bootstrap.css' rel='stylesheet' /> <link href='http://www.leifengta.com.cn/wenda/bootstrap-theme.css' rel='stylesheet' /></head><body ng-controller='defaultCtrl'><p class='panel panel-primary'> <h3 class='panel-heading'>Products</h3> <p ng-view></p></p></body></html>

/** products.js **/angular.module('exampleApp', ['ngRoute']) .config(function ($routeProvider) { $routeProvider.when('/list', {templateUrl: '/tableView.html'}); $routeProvider.when('/edit', {templateUrl: '/editorView.html'}); $routeProvider.when('/create', {templateUrl: '/editorView.html'}); $routeProvider.otherwise({templateUrl: '/tableView.html'});}) .controller('defaultCtrl', function ($scope, $location) { $scope.currentProduct = null; $scope.listProducts = function () {$scope.products = [ {id: 0, name: 'Dummy1', category: 'Test', price: 1.25}, {id: 1, name: 'Dummy2', category: 'Test', price: 2.45}, {id: 2, name: 'Dummy3', category: 'Test', price: 4.25}]; }; $scope.deleteProduct = function (product) {$scope.products.splice($scope.products.indexOf(product), 1); }; $scope.createProduct = function (product) {$scope.products.push(product);$location.path('/list'); }; $scope.updateProduct = function (product) {for (var i = 0; i < $scope.products.length; i++) { if ($scope.products[i].id === product.id) {$scope.products[i] = product;break; }}$location.path('/list'); }; $scope.editOrCreateProduct = function (product) {$scope.currentProduct = product ? angular.copy(product) : {};$location.path('/edit'); }; $scope.saveEdit = function (product) {if (angular.isDefined(product.id)) { $scope.updateProduct(product);} else { $scope.createProduct(product);} }; $scope.cancelEdit = function () {$scope.currentProduct = {};$location.path('/list'); }; $scope.listProducts();});

/** tableView.html(略) **/

/** editorView.html(略) **/

程序無法執(zhí)行(如圖):javascript - 請(qǐng)教AngularJS的ngRoute問題:為何這段程序無法執(zhí)行?問題出在哪?

問題解答

回答1:

$routeProvider定義路徑時(shí),不應(yīng)該以'/'開頭javascript - 請(qǐng)教AngularJS的ngRoute問題:為何這段程序無法執(zhí)行?問題出在哪?

回答2:

用stateProvider

標(biāo)簽: JavaScript
相關(guān)文章:
主站蜘蛛池模板: 亚洲国产伊人 | 欧美一道本 | 91视频免费在线看 | 7mav视频| 欧美影音| 国产另类视频 | 国产亚洲91 | 青青草在线免费视频 | 911香蕉| 欧美极品在线 | 黄色小网站在线观看 | 国产影视一区二区 | 久久国产免费观看 | 国产午夜精品在线 | 亚洲深夜福利视频 | 99精品视频免费 | 亚洲精品免费看 | 亚洲男人av | 成人观看免费视频 | 精彩久久 | 国产主播精品 | 亚洲精品资源 | 亚洲国产日韩在线 | 午夜在线观看影院 | 草视频在线 | 国产91对白在线播放 | 久久久精彩视频 | 伊人手机视频 | 一区二区视频网站 | 婷婷俺也去 | 青青青视频在线免费观看 | 欧美日黄 | 免费av网站在线播放 | 亚洲毛毛片 | 一起草av在线 | 婷婷视频 | 免费av在线| 三级天堂 | 亚洲一区二区三区欧美 | 国产精品v欧美精品v日韩 | 国产精品久久久久久亚洲影视 |