如何实现在angularjs一个导航栏如何实现、angularjs

由网友(安然°)分享简介:与angularjs为我创建了一个导航栏的新手开始。它有几个子菜单。但我不完全知道什么是对付使用angularjs的最佳做法。我想跟踪当前选择的菜单项,使其活跃,并根据选择改变呈现的模板。Starting with angularjs as a newbie I have created a navigation b...

与angularjs为我创建了一个导航栏的新手开始。它有几个子菜单。但我不完全知道什么是对付使用angularjs的最佳做法。我想跟踪当前选择的菜单项,使其活跃,并根据选择改变呈现的模板。

Starting with angularjs as a newbie I have created a navigation bar. It has several sub menus. But I am not completely sure what is the best practice to deal with it using angularjs. I would like to keep track of the current selected menu item to make it 'active' and change the rendered template depending on the selection.

我要寻找一些例子或者一些例如code,可以在生产环境中使用。

I am looking for some examples or some example code, that can be used in production environment.

对不起,这个非常普通的问题,但我希望有人能帮助我。

Sorry for this very generic question, but I hope someone can help me.

推荐答案

看一看 angular- UI / UI路由器。它增加了一个名为观点和各州您的应用程序。您可以定义的基础上,状态,在你的主模板区的程序是,显示了一定的模板+控制器。

Have a look at angular-ui/ui-router. It adds named views and states to your app. You can define "areas" in your main template that, based on the "state" your app is in, display a certain template+controller.

编辑:是的,$位置可以够一个简单的应用程序,但你一每屏控制器获取要你开始意识到你需要更多的东西100线$​​范围$表定义的时间

yes, $location could be enough for a simple application but by the time your one-per-screen controller gets to be 100 lines of $scope.$watch definitions you start realizing you need something more.

阅读全文

相关推荐

最新文章