披露:已经彻底检查了重复和主题/离题。这是我室友在尝试时也遇到的问题,因此这显然是一个常见问题。我发现其他人也有类似的问题,但是已经解决了一些无法解决这个特定问题的问题。
我对所有这些框架都比较陌生,但我真的可以更多地关注这一点。我正在使用 generator-angular-fullstack,当我只是生成一个指令并且 templateurl 没有像标题暗示的那样呈现时。由于 Angular 不能那样工作,因此网络上没有任何进展。我尝试编写自己的指令,但也不太顺利,只能使用 template: 而不是 templateurl。如果我尝试
ng-include="'app/geoData/geoData.html'"
在 main.html 上它填充得很好,但我发现这是一条糟糕的路线,考虑到 html 在我的自定义指令下看起来非常干净,并且网络上还有另一个调用最终会减慢一切。有什么我想念的吗?generator-angular-fullstack 是否有尚未更新的新错误?
这是我的指令,它在 index.html 中调用的 main.html 上调用。
'use strict';
angular.module('dangerzoneApp')
.directive('geoData', function () {
return {
templateUrl: 'app/geoData/geoData.html',
restrict: 'EA',
link: function (scope, element, attrs) {
}
};
});
这是我的 main.html
<div ng-include="'components/navbar/navbar.html'"></div>
<header class="hero-unit" id="banner">
<div class="container" >
<h1>O'HAI, there!</h1>
<geo-data></geo-data>
<img src="assets/images/yeoman.png" alt="I'm Yeoman">
</div>
</header>
<div class="container">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Features:</h1>
<ul class="nav nav-tabs nav-stacked col-md-4 col-lg-4 col-sm-6" ng-repeat="thing in awesomeThings">
<li><a href="#" tooltip="{{thing.info}}">{{thing.name}}<button type="button" class="close" ng-click="deleteThing(thing)">×</button></a></li>
</ul>
</div>
</div>
<form class="thing-form">
<label>Syncs in realtime across clients</label>
<p class="input-group">
<input type="text" class="form-control" placeholder="Add a new thing here." ng-model="newThing">
<span class="input-group-btn">
<button type="submit" class="btn btn-primary" ng-click="addThing()">Add New</button>
</span>
</p>
</form>
</div>
<footer class="footer">
<div class="container">
<p>Angular Fullstack v2.0.13 |
<a href="https://twitter.com/tyhenkel">@tyhenkel</a> |
<a href="https://github.com/DaftMonk/generator-angular-fullstack/issues?state=open">Issues</a></p>
</div>
</footer>
这是我的 index.html
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<base href="/">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css(client) app/vendor.css -->
<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.css" />
<!-- endbower -->
<!-- endbuild -->
<!-- build:css({.tmp,client}) app/app.css -->
<link rel="stylesheet" href="app/app.css">
<!-- injector:css -->
<link rel="stylesheet" href="app/account/login/login.css">
<link rel="stylesheet" href="app/admin/admin.css">
<link rel="stylesheet" href="app/app.css">
<link rel="stylesheet" href="app/geoData/geoData.css">
<link rel="stylesheet" href="app/main/main.css">
<link rel="stylesheet" href="components/modal/modal.css">
<!-- endinjector -->
<!-- endbuild -->
</head>
<body ng-app="dangerzoneApp" geo-data>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<geo-data></geo-data>
<!-- Add your site or application content here -->
<div ui-view=""><geo-data></geo-data></div>
<geo-data></geo-data>
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-X');
ga('send', 'pageview');
</script>
<!--[if lt IE 9]>
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/json3/lib/json3.min.js"></script>
<![endif]-->
<!-- build:js({client,node_modules}) app/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/lodash/dist/lodash.compat.js"></script>
<script src="bower_components/angular-socket-io/socket.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<!-- endbower -->
<script src="socket.io-client/socket.io.js"></script>
<!-- endbuild -->
<!-- build:js({.tmp,client}) app/app.js -->
<script src="app/app.js"></script>
<!-- injector:js -->
<script src="app/account/account.js"></script>
<script src="app/account/login/login.controller.js"></script>
<script src="app/account/settings/settings.controller.js"></script>
<script src="app/account/signup/signup.controller.js"></script>
<script src="app/admin/admin.controller.js"></script>
<script src="app/admin/admin.js"></script>
<script src="app/main/main.controller.js"></script>
<script src="app/main/main.js"></script>
<script src="app/message/message.controller.js"></script>
<script src="components/auth/auth.service.js"></script>
<script src="components/auth/user.service.js"></script>
<script src="components/modal/modal.service.js"></script>
<script src="components/mongoose-error/mongoose-error.directive.js"></script>
<script src="components/navbar/navbar.controller.js"></script>
<script src="components/socket/socket.service.js"></script>
<!-- endinjector -->
<!-- endbuild -->
</body>
</html>
文件结构:这是 generator-angular-fullstack 的标准文件结构。
├── client
│ ├── app - All of our app specific components go in here
│ ├── assets - Custom assets: fonts, images, etc…
│ ├── components - Our reusable components, non-specific to app
app下文件夹是如何设置的。主要的
├── main.js - Routes
├── main.controller.js - Controller for our main route
├── main.controller.spec.js - Test
├── main.html - View
└── main.css - Styles
app.geoData 文件夹是如何设置的
├── geoData.directive.js - Controller for our main route
├── geoData.directive.spec.js - Test
├── geoData.html - View
└── geoData.css - Styles
我提前为任何错别字道歉。我正在寻求帮助而不是聪明的嘴巴。请保持礼貌和礼貌,因为这是我第一次深入研究这些框架。也提前谢谢!