gpt4 book ai didi

javascript - AngularJS 指令未显示

转载 作者:行者123 更新时间:2023-11-28 11:22:58 24 4
gpt4 key购买 nike

这已经让我彻底陷入困境了好几个小时。

我有我的 app.js

    'use strict';

/**
* @ngdoc overview
* @name myWellnessTrackerApp
* @description
* # myWellnessTrackerApp
*
* Main module of the application.
*/
angular
.module('myWellnessTrackerApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch'
])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/about', {
templateUrl: 'views/about.html',
controller: 'AboutCtrl'
})
.otherwise({
redirectTo: '/'
});
});

我的 main.html 在加载时加载到主页中,如上所示。

<innerPageHeader> </innerPageHeader>

我的指令。

angular.module('myWellnessTrackerApp')
.directive('innerPageHeader' ,function () {
return {
template: '<h4>TEST</h4>',
restrict: 'E'
};
});

还有我的index.html脚本:

<!-- build:js(**/*) scripts/vendor.js -->
<!-- bower:js -->
<script src="components/modernizr/modernizr.js"></script>
<script src="components/jquery/dist/jquery.js"></script>
<script src="components/angular/angular.js"></script>
<script src="components/angular-animate/angular-animate.js"></script>
<script src="components/angular-cookies/angular-cookies.js"></script>
<script src="components/angular-resource/angular-resource.js"></script>
<script src="components/angular-route/angular-route.js"></script>
<script src="components/angular-sanitize/angular-sanitize.js"></script>
<script src="components/angular-touch/angular-touch.js"></script>
<script src="components/fastclick/lib/fastclick.js"></script>
<script src="components/jquery.cookie/jquery.cookie.js"></script>
<script src="components/jquery-placeholder/jquery.placeholder.js"></script>
<script src="components/foundation/js/foundation.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/controllers/about.js"></script>
<script src="scripts/directives/innerpageheader.js"></script>

加载页面时仅显示

<innerPageHeader> </innerPageHeader>

没有应有的指令内容

<innerPageHeader><h4>TEST</h4> </innerPageHeader>

最佳答案

您需要按如下方式使用该指令。

<inner-page-header></inner-page-header>

关于javascript - AngularJS 指令未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28451034/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com