简体   繁体   English

单页应用程序中使用角度导航栏

[英]navigation bar in single page app using angular

I've tried to find the answer to my problem with no luck. 我试图找到解决我的问题的答案,但是没有运气。 I'm new to web development and I've been trying to create a simple app using angularjs and bootstrap . 我是Web开发的新手,我一直在尝试使用angularjsbootstrap创建一个简单的应用bootstrap There's no much content on my pages, only a couple of inputs and buttons that do nothing. 我的页面上没有太多内容,只有几个inputsbuttons什么都不做。 I placed ng-view in the index.html page as I saw in many tutorials and that allows me to navigate to all my pages. 正如我在许多教程中看到的那样,我将ng-view放置在index.html页面中,这使我可以导航到所有页面。 I'm trying to add a navigation bar to all my pages once a user logs in, so I placed another ng-view on my home(page after user logs in), but it seems that angular allows only one view for each app. 我试图在用户登录后向所有页面添加导航栏,因此我在首页上放置了另一个ng-view (用户登录后的页面),但似乎角度只允许每个应用一个视图。 And also it doesn't allow nested app. 而且它也不允许嵌套应用。 If I'm wrong, please correct me (that's what I understood from my Google 'research'). 如果我错了,请纠正我(这是我从Google的“研究”中了解到的)。 So, my question is: how can I add a navigation bar(or any same html content) to all my pages after the user logs in without copying the same code in each html page? 因此,我的问题是:在用户登录后如何在我的所有页面中添加导航栏(或任何相同的html内容)而不在每个html页面中复制相同的代码? Btw, I had this working with jQuery , but I don't know how to do it using angularjs Thanks! 顺便说一句,我已经使用jQuery ,但是我不知道如何使用angularjs来做。谢谢!

You can use Angular Directive that use a template to create a custom tag and you can use a controller only for this directive. 您可以使用使用模板的Angular Directive创建自定义标签,并且只能将控制器用于此指令。 Call this tag to all pages when logging. 记录时将此标签调用到所有页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM