我想根据services.js
中定义的范围变量将动态内容添加到我的侧边菜单中目前用户数组的内容未加载。
我的app.js定义控制器。
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('menu', {
url: '/menu',
templateUrl: 'templates/menu.html',
controller: 'MenuCtrl'
})
controllers.js
angular.module('starter.controllers', [])
.controller('MenuCtrl', function($scope, UserInfo ) {
$scope.user = UserInfo;
})
services.js
angular.module('starter.services', [])
.factory('UserInfo', function() {
var User = {
fname : "First",
lname : "Last",
};
return User;
});
menu.html
<ion-side-menus enable-menu-with-back-views="false">
<ion-side-menu-content>
<ion-nav-bar class="bar-stable">
<ion-nav-back-button>
</ion-nav-back-button>
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" menu-toggle="left">
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-nav-view name="menuContent"></ion-nav-view>
</ion-side-menu-content>
<ion-side-menu side="left">
<ion-header-bar class="bar-stable">
<h1 class="title">{{user.fname}} {{user.lname}}</h1>
</ion-header-bar>
<ion-content>
</ion-content>
</ion-side-menu>
</ion-side-menus>