Javascript 单击a标记时,Angular不更新页面

Javascript 单击a标记时,Angular不更新页面,javascript,angularjs,angularjs-directive,Javascript,Angularjs,Angularjs Directive,我有一个来自twitter引导的标签导航,我用它来导航我的页面。 当我点击tournaments时,视图不会更新,但url现在显示#/tournaments: 但如果我单击url栏并按enter键,则会更改视图: 我已经用一个构建文件夹和一个编译文件夹设置了这个项目。当项目位于build文件夹中时,一切正常。然后我使用grunt来压缩和缩小文件,并将其放入已编译的文件夹中,这时它开始像这样工作 我使用r.js进行浓缩和缩小(我使用的是require.js),在这个过程中没有出现错误。所有

我有一个来自twitter引导的标签导航,我用它来导航我的页面。

当我点击
tournaments
时,视图不会更新,但url现在显示
#/tournaments

但如果我单击url栏并按enter键,则会更改视图:

我已经用一个构建文件夹和一个编译文件夹设置了这个项目。当项目位于build文件夹中时,一切正常。然后我使用grunt来压缩和缩小文件,并将其放入已编译的文件夹中,这时它开始像这样工作

我使用
r.js
进行浓缩和缩小(我使用的是
require.js
),在这个过程中没有出现错误。所有html视图也被正确复制,正如我强制刷新浏览器窗口时看到的那样

这就好像angular不会对位置的变化做出反应,但是
活动选项卡
,即标题为灰色的选项卡,可以正确地交换。只是视图没有更新

有人知道这是什么吗

我已经把标签放在了它自己的指令中:

define(['angular'], function (ng) {
var directives = ng.module('directives', []);

/* top navigation tabs */
directives.directive('tabset', function () {
    return {
        restrict: 'E',
        scope: {},
        transclude: true,
        replace: true,
        template: '<ul class="nav nav-tabs" ng-transclude></ul>'
    };
})
.directive('tab', ['$location', function ($location) {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            route: '@',
            title: '@'
        },
        link: function (scope, element, attrs) {
            var route = attrs.route;

            scope.location = $location;
            scope.active = false;

            scope.$watch('location.path()', function (new_route) {
                scope.active = route === new_route;
            });
        },
        template: '<li data-ng-class="{active: active}">' +
                    '<a href="#{{route}}">{{title}}</a>' +
                    '</li>'
    };
}]);

return directives;
});
define(['angular'],函数(ng){
var directives=ng.module('directives',[]);
/*顶部导航选项卡*/
指令('tabset',函数(){
返回{
限制:'E',
作用域:{},
是的,
替换:正确,
模板:'
    ' }; }) .directive('tab',['$location',function($location){ 返回{ 限制:'E', 替换:正确, 范围:{ 路线:“@”, 标题:“@” }, 链接:函数(范围、元素、属性){ var-route=attrs.route; scope.location=$location; scope.active=false; 作用域$watch('location.path()',函数(新路径){ scope.active=路由===新路由; }); }, 模板:'
  • '+ '' + “
  • ” }; }]); 返回指令; });
    我是这样使用它的:

    <tabset>
        <tab data-route="/home" data-title="Home"></tab>
        <tab data-route="/tournaments" data-title="Tournaments"></tab>
        <tab data-route="/about" data-title="About"></tab>
    </tabset>
    
    
    
    问题发生在缩小和浓缩之后

    编辑:它似乎没有加载所有源:

    build
    路径中:

    在编译后的路径中:

    当我单击
    build
    路径中的一个链接时,会为我需要的视图发送一个http GET请求,这在
    compile
    路径中不会发生

    ../build/#/…
    有效。
    ../compiled/#/…
    不起作用。

    您是否尝试使用ng href而不是href?它给出的结果与
    href
    相同。请尝试使用
    $location.path()
    中的
    ng click
    ng click='$location.path(YourUrl)
    @Satpal我无法获得
    $location.path({{route}}})
    来工作。像这样尝试:
    '{{title}}
    '{{title}}'
    。它们都没有打印url。它只是尝试导航到
    编译的/$location(/home)
    (或任何其他路径)。