在我的页面顶部,我有
=============================================== ===============================
<html lang="en" data-ng-app="app">
<head>
<style>
/* This helps the ng-show/ng-hide animations start at the right place. */
/* Since Angular has this but needs to load, this gives us the class early. */
.ng-hide {
display: none !important;
}
</style>
=============================================== =============================
我体内的身体越来越深。
=============================================== =============================
<div class="row row-offcanvas row-offcanvas-left" data-ng-controller="dashboard" data-ng-init="vm=dashboard()">
=============================================== ===
我想在起始页面的正文中呈现以下内容
=============================================== ===
<span class="bold">{{vm.title}}</span> Messages
=============================================== ===
这仅在开始页面上。我想使用Angular进行绑定而不是单页。 有任何想法吗。我尝试创建一个回到第一页的路线,但是你知道它导致了一个无限循环。我认为ng-init是要走的路,但它不起作用。 感谢
仪表板是一个控制器。这是来自John Papa对Pluralsight的Angular Hotowel示例。
(function () {
'use strict';
var controllerId = 'dashboard';
angular.module('app').controller(controllerId, ['common', 'datacontext', dashboard]);
function dashboard(common, datacontext) {
var getLogFn = common.logger.getLogFn;
var log = getLogFn(controllerId);
var vm = this;
vm.news = {
title: 'hottowel',
description: 'Welcome'
};
vm.messageCount = 0;
vm.people = [];
vm.title = 'Dashboard';
activate();
function activate() {
var promises = [getMessageCount(), getPeople()];
common.activateController(promises, controllerId)
.then(function () { log('Activated Dashboard View'); });
}
function getMessageCount() {
return datacontext.getMessageCount().then(function (data) {
return vm.messageCount = data;
});
}
function getPeople() {
return datacontext.getPeople().then(function (data) {
return vm.people = data;
});
}
}
})();
答案 0 :(得分:1)
为了让yoh能够呼叫dashboard()
,它应该是控制器范围内的一个功能(事实并非如此)。
我相信您正在尝试使用controller as
语法( more info ):
<div ... ng-controller="dashboard as vm">
...
{{vm.title}}
答案 1 :(得分:0)
如果您愿意,您不能使用路由器,也不能在角度应用程序中设置路由,这样就不会与您的后端路由器发生冲突