【发布时间】:2017-07-08 07:59:28
【问题描述】:
我正在制作单页应用程序
我的配置:
var app = angular.module('menuCardMaker', ['ngRoute']);
app.config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/wines', {
templateUrl: 'templates/wine/wine.html',
controller: 'WineController'
})
.when('/wines/delete/:id', {
templateUrl: 'templates/wine/wine.html',
controller: 'WineController'
})
我的 HTML:
<table>
<tr>
<td class="head">Name</td>
</tr>
<tr ng-repeat="wine in winesFromStorage">
<td>{{ wine.name }}</td>
<td><a ng-href="#/wines/delete/{{ wine.id }}" ng-click="remove()">Delete</a></td>
</tr>
</table>
当用户单击删除时,页面在http://127.0.0.1:8080/#/wines/delete/1 上的 URL(例如)上加载。它会删除我的 LocalStorage 中的记录,但它不会像我期望的那样从我的配置中的 templateUrl 中“刷新”我的页面。
用户必须在表格显示正确数据之前重新加载页面。有什么想法可以指导我找到解决方案吗?
【问题讨论】:
标签: javascript angularjs single-page-application ngroute