我有一个简单的Angular JS场景.我在一个视图中显示了一个专家列表,该列表包含编辑专家的操作,这将在另一个视图中完成.这些视图来自服务器,不在一个文件中.它们不会一起装载.
<!-- experts.html -->
<div ng-controller='expertController'>
<!-- showing the list of experts here -->
</div>
Run Code Online (Sandbox Code Playgroud)
在服务器上的另一个文件中我有:
<!-- expert.html -->
<div ng-controller='expertController'>
<!-- a form to edit/add an expert -->
</div>
Run Code Online (Sandbox Code Playgroud)
我的控制器是:
app.controller('expertController', function ($scope) {
$scope.getExperts = function () {
_.get('/expert/getexperts/', null, function (data) {
$scope.$apply(function () {
$scope.experts = data;
});
});
};
$scope.editExpert = function (index) {
_.get('/expert/getexpert/', { id: $scope.experts[index].Id }, function (data) {
$scope.$apply(function () {
$scope.expert = data;
});
});
};
});
Run Code Online (Sandbox Code Playgroud)
但是,编辑表单中不会显示任何数据.我使用Batarang检查了范围,但是expert …