Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用codeigniter和Angularjs在导航中添加引导活动类_Angularjs_Codeigniter - Fatal编程技术网

使用codeigniter和Angularjs在导航中添加引导活动类

使用codeigniter和Angularjs在导航中添加引导活动类,angularjs,codeigniter,Angularjs,Codeigniter,我想将引导活动类添加到导航中。在导航中我使用了href 这是codeigniter链接,意味着将重定向到新页面,并通过angularjs将活动类添加到其中。我的导航是 <ul> <li ng-class="{active:isActive('/c_home')}"><a href="<?php echo base_url();?>c_home>home</a></li> <li ng-class="{active:is

我想将引导活动类添加到导航中。在导航中我使用了href

这是codeigniter链接,意味着将重定向到新页面,并通过angularjs将活动类添加到其中。我的导航是

<ul>
<li ng-class="{active:isActive('/c_home')}"><a href="<?php echo base_url();?>c_home>home</a></li>
<li ng-class="{active:isActive('/c_contact')}" ><a href="<?php echo base_url();?>c_contact>contact</a></li>
</ul>
return currentLocation==$location.path()

}

我的问题是活动类在第二次单击后应用。我的意思是说,第一次点击不起作用


我想,在加载codeigniter url之前,angularjs函数调用我没有将CI与angularjs一起使用,但当我想将活动类放到导航栏的链接时,我使用的是:

$(document).ready(function () {
    if(window.location.href.indexOf("part_of_uri") > -1) {
       $("#menu_item_a").removeClass('active');
       $("#menu_item_b").addClass('active');
    } else if (window.location.href.indexOf("another_part_of_uri") > -1) {
        $("#menu_item_b").removeClass('active');
        $("#menu_item_a").addClass('active');
    } ... // and goes on
});
这样做的目的是,如果字符串
part\u of_uri
与url片段匹配,则从
menu\u item\u a
中删除活动类,并将其应用于
menu\u item\b
等,使用所需的任意多个菜单项

希望对你有所帮助

$(document).ready(function () {
    if(window.location.href.indexOf("part_of_uri") > -1) {
       $("#menu_item_a").removeClass('active');
       $("#menu_item_b").addClass('active');
    } else if (window.location.href.indexOf("another_part_of_uri") > -1) {
        $("#menu_item_b").removeClass('active');
        $("#menu_item_a").addClass('active');
    } ... // and goes on
});