$ route.current返回undefined?

时间:2015-09-05 14:50:19

标签: javascript angularjs

.when('/',{
    controller : 'secondController',
    activeTab : 'admin'
})

app.controller('secondController', ['$route', function($route){
    console.log($route.current.activeTab);
}])

为什么我在这里未定义?我可以在console.log($route)时看到这个对象,这很奇怪。

1 个答案:

答案 0 :(得分:2)

$ route.current在#!/bin/bash csv2000="`ls *_2000.csv`" csv2001="`ls *_2001.csv`" csv2002="`ls *_2002.csv`" csv2003="`ls *_2003.csv`" csv2004="`ls *_2004.csv`" csv2005="`ls *_2005.csv`" csv2006="`ls *_2006.csv`" csv2007="`ls *_2007.csv`" csv2008="`ls *_2008.csv`" csv2009="`ls *_2009.csv`" csv2010="`ls *_2010.csv`" csv2011="`ls *_2011.csv`" csv2012="`ls *_2012.csv`" csv2013="`ls *_2013.csv`" csv2014="`ls *_2014.csv`" csv2015="`ls *_2015.csv`" temp01_csv="temp01.csv" temp02_csv="temp02.csv" temp03_csv="temp03.csv" temp04_csv="temp04.csv" temp05_csv="temp05.csv" temp06_csv="temp06.csv" temp07_csv="temp07.csv" temp08_csv="temp08.csv" temp09_csv="temp09.csv" temp10_csv="temp10.csv" temp11_csv="temp11.csv" temp12_csv="temp12.csv" temp13_csv="temp13.csv" temp14_csv="temp14.csv" temp15_csv="temp15.csv" join -a1 -t';' $csv2000 $csv2001 > $temp01_csv join -a1 -t';' $csv2002 $csv2003 > $temp02_csv join -a1 -t';' $csv2004 $csv2005 > $temp03_csv join -a1 -t';' $csv2006 $csv2007 > $temp04_csv join -a1 -t';' $csv2008 $csv2009 > $temp05_csv join -a1 -t';' $csv2010 $csv2011 > $temp06_csv join -a1 -t';' $csv2012 $csv2013 > $temp07_csv join -a1 -t';' $csv2014 $csv2015 > $temp08_csv join -a1 -t';' $temp01_csv $temp02_csv > $temp09_csv join -a1 -t';' $temp03_csv $temp04_csv > $temp10_csv join -a1 -t';' $temp05_csv $temp06_csv > $temp11_csv join -a1 -t';' $temp07_csv $temp08_csv > $temp12_csv join -a1 -t';' $temp09_csv $temp10_csv > $temp13_csv join -a1 -t';' $temp11_csv $temp12_csv > $temp14_csv join -a1 -t';' $temp13_csv $temp14_csv > final.csv #done exit 0 内或控制器中可用。但是,如果要在解决路由之前访问当前路由(或预期的当前路由),例如在$rootScope.$on '$locationChangeSuccess'或运行或配置功能中,则可以使用$rootScope.$on "$locationChangeStart"

但要注意带参数的路由会导致错误$route.routes[$location.path()],这一点很重要,因为$route.routes[$location.path()]$route.routes[key]的密钥不匹配。您可以通过控制台记录$location.path()$location.path()在运行功能中向您自己证明这一点。

如果您在路线中添加了额外的自定义属性,则可以使用$route.routes轻松访问这些属性     $route.routes[$location.path()]