我做错了什么?列表部分未填充到视图中,但“添加”页面是。每个都通过指令连接。
控制台没有丢失错误,我不相信问题在控制器内,因为我的应用程序在我尝试使用指令之前工作。
路线:
//ROUTING ---------------------------------------
UsersApp.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('List', {
url: "/List",
template: "<list-Users user='user' users-List='usersList'></list-Users>",
})
.state('AddUser', {
url: "/Add",
template: "<add-User new-User='newUser' users-List='usersList' add-New='addNew(newUser)'></add-User>",
})
});
指令:
UsersApp.directive('listUsers', function() {
return {
restrict: 'E',
replace: true,
templateUrl: '../../partials/userslist.html',
scope: {
usersList: '=',
user: '=',
}
};
});
UsersApp.directive('addUser', function() {
return {
restrict: 'E',
replace: true,
templateUrl: '../../partials/adduser.html',
scope: {
newUser: '=',
addNew: '&'
}
};
});
列表页面:
<div>
<h2 style="display:table; width:35%; position:relative; font-family:sans-serif;">Users:</h2>
<div class="userInfo">
<br/>
<div id="listInfo">
<ul style="list-style-type: none;">
<li ng-repeat="user in usersList">
<p class="userData"><a style="cursor:pointer;" ng-click="profilePopulate(user)" ng-model="user.firstName" ui-sref="UserProfile({id: user._id})">{{ user.firstName }} {{ user.lastName }}</a></p>
<br/>
</li>
</ul>
</div>
</div>
</div>