电子+ AngularJS 我正在做一些基本的东西:我正在尝试添加页眉和页脚,它将在每个页面上显示。 所以我有这样的app.js:
'use strict';
let app = angular.module('marks', ['ngRoute']);
app.controller('ctrl', ($scope) => {})
.config(($logProvider, $routeProvider) => {
$logProvider.debugEnabled(true);
$routeProvider
.when('/', {
templateUrl: 'html/home.html'
})
.when('/login', {
templateUrl: 'html/login.html'
})
.when('/teachers', {
// controller: 'js/teachers.controller.js',
templateUrl: 'html/teachers.html'
})
.when('/students', {
// controller: 'js/students.controller.js',
templateUrl: 'html/students.html'
})
.when('/404', {
templateUrl: 'html/404.html'
})
.otherwise({ redirectTo: '/404' });
});
footer.controller.js:
angular.module('marks').controller('MarksFooterController', ['$scope', ($scope) => {}]);
footer.directive.js:
angular.module('marks').directive('marksFooter', () => {
return {
restrict: 'EAC',
controller: 'MarksFooterController',
templateUrl: '../html/marks-footer.html'
};
});
马克 - footer.html:
<div>
<h3>2017</h3>
</div>
和标题相同。
的index.html
<!DOCTYPE html>
<html>
<head>
<script src="../../bower_components/angular/angular.js"></script>
<script src="../../bower_components/angular-resource/angular-resource.js"></script>
<script src="../../bower_components/angular-route/angular-route.js></script>
</head>
<body ng-app="marks">
<div class="tile is-ancestor is-12">
<div class="tile is-vertical is-parent is-9">
<ng-view></ng-view>
</div>
</div>
<script>
require('./app.js');
</script>
</body>
</html>
当我运行应用程序时,我没有错误,但指令是空的(但它们也得到了参数),那么问题是什么?
使用DevTools的屏幕截图:我认为我以某种方式搞砸了控制器,但我不确定。 This answer没有帮助。 感谢任何帮助
UPDATE
现在我尝试以某种方式加载模板(可能有一些标记位置的变化帮助),但应用程序无法找到它。 DevTools
- > Sources
显示没有html
文件夹(screenshot)。我应该在哪里导入它?
解决了 解决方案是:
<head>
中的所有控制器和指令但是我仍然在寻找如何在.html中避免这么多的导入
问题是你如何包含你的app.js脚本。它应作为标记包含在标题或任何其他位置。