I want to add a static view in ng-admin, where no backend call is required. Something like an about section. Is there a way to do that?
问问题
199 次
1 回答
1
没有什么特别的事情可做(这是很常见的角度方式):
只需在 ng-admin.js 文件中添加一个新路由(通过 $stateProvider 或 $routeProvider):
(function () {
"use strict";
var app = angular.module('NgAdminBackend', [
'ng-admin',
'myNewModule', //first add a new module
]);
app.config(['NgAdminConfigurationProvider', 'RestangularProvider', '$stateProvider',
function (NgAdminConfigurationProvider, RestangularProvider, $stateProvider) {
var nga = NgAdminConfigurationProvider;
// API Endpoint
var backend = nga.application('My Backend', false)
.baseApiUrl(config.BASEAPIURL);
// plus if you want a menu link
backend.menu(nga.menu()
.addChild(nga.menu().link('/myCustomLink').title('Hello').icon('<span class="glyphicon glyphicon-home"></span>'))
);
// new routes here
$stateProvider
.state('myCustomState', {
url: '/myCustomLink',
controller: 'myCustomController',
templateUrl: 'modules/myCustomTemplate.html' // example of location of your new page template
})
;
...
nga.configure(backend);
}]);
}());
然后在您的新控制器中(位置示例:scripts/models/myCustomController.js):
'use strict';
var app = angular.module('myNewModule', []);
app.controller('myCustomController',
['$scope',
function ($scope) {
// add your logic here
}]);
最后,不要忘记在 index.html 中添加指向新控制器的链接:
<script src="scripts/models/myCustomController.js"></script>
于 2016-11-22T08:43:22.570 回答