【发布时间】:2015-12-18 17:04:44
【问题描述】:
我正在尝试使用 Angularjs。问题是,ng-repeat 在路由中时不起作用。它在不在路线中时工作。
这是我目前所拥有的: 查看链接..
这很好用... http://plnkr.co/edit/1syQFJdMyRUYncBrREue?p=preview
但在这方面,它现在不起作用..(在人中导航) http://plnkr.co/edit/gsi2mZpnU0YJUUOa20DO?p=preview
html
<html ng-app="myApp">
<head>
<title>Confirm Dialog Box</title>
<!--
in the link above i create a custom dialog box
-->
</head>
<body>
<div ng-controller="loglistController">
<table>
<tr ng-repeat="x in names">
<td onclick="showDialog()" ng-click="showInEdit(x)">{{ x.Name }}</td>
<td onclick="showDialog()" ng-click="showInEdit(x)">{{ x.Country }}</td>
</tr>
</table>
<div id="white-background">
</div>
<div id="dlgbox">
<div id="dlg-header"><h3>Information</h3></div>
<div id="dlg-body">
Name <input type="text" ng-model="selectedPerson.Name" /><br/>
Country <input type="text" ng-model="selectedPerson.Country" /><br/>
</div>
<div id="dlg-footer">
<button onclick="dlgOK()">Update</button>
<button onclick="dlgCancel()">Exit</button>
</div>
</div>
角度
var myApp = angular.module('myApp', ['ngRoute']);
myApp.controller('loglistController', ['$scope', '$http', function ($scope, $http) {
$scope.data=[];
$scope.selectedPerson={ Name:"",Country:""};
$http.get("loglistajax.php")
.then(function (response) {$scope.names = response.data.records;});
$scope.showInEdit=function(person){
$scope.selectedPerson = person;
};
}]);
【问题讨论】:
-
对于初学者,您已经在 app.js 和 list.html 中定义了 MyApp 和 loglistController 并将其从其中一个中移除,然后查看您的位置。我的建议是从 list.html 中删除它
标签: javascript php angularjs