javascript – Angular不在表行中显示数据. ng-repeat不起作用

我正在尝试使用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;
    };



 }]);

解决方法:

这是(有点)fixed plunker,但是我在你的代码中发现了以下问题:

>你有双控制器:loglistController定义两次,一次在app.js内,然后再在list.html内.

你写了以下这一行

< tr ng-repeat =“x in data”>

认为它会从loglistController的$scope.data读取,但您的应用程序似乎正在考虑第一个控制器,因此您的控制器范围没有数据属性.我解决了用app.html里面的一个替换app.js中的控制器.

考虑一下,我猜你不允许在它的模板中放置一个路由控制器的代码,所以你最好避免在将来这样做!
>当url为’/’时,你的app.js’templateUrl不存在,这会引发错误.我用’list.html’替换它解决了.我很确定这不是你想要的东西,但它需要让它发挥作用.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...