在我的页面顶部,我有
==================================================== ==============================
<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;
});
}
}
})();