【问题标题】:angularjs $location.path not workingangularjs $location.path 不起作用
【发布时间】:2014-12-25 22:44:02
【问题描述】:

我正在使用 angularjs 位置路径并面临非常奇怪的问题..

我的重定位功能:

        $scope.relocate = function(chat_id) {
        $location.path('/chat/' + chat_id);
    };

在下一个代码中:

    <div class="scrollable-content">
    <div class="recent-chat"  ng-click="relocate({{recent_chat.id}})">
        <img src="./img/usericon.png" class="user-icon" />
        <h2>{{recent_chat.mate.display_name}}</h2>
        <p>{{recent_chat.last_message_content}}</p> 
        <img src="./img/fb.png" class="fb-icon" alt="Facebook User" />
        <div class="clear"></div>
    </div>
    <div masonry load-images="false" class="chat-list"">
        <div class="masonry-brick chat-item" ng-repeat="chat in chatlist" ng-class="{unread: chat.unread==true}" ng-click="relocate({{chat.id}})">
            <img src="./img/usericon.png" class="user-icon" />
            <img src="./img/newmessage.png" class="new-message-icon" alt="New Message" />
            <h2>{{chat.mate.display_name}}</h2>
            <p>{{chat.last_message_content}}</p>
            <img src="./img/fb.png" class="fb-icon" alt="Facebook User" />
            <div class="clear"></div>
        </div>
    </div>
</div>

relocate 功能仅适用于聊天列表类块,但不适用于最近聊天块。

当我单击最近聊天 div 时,我会进入聊天/未定义状态,尽管当我检查它为 {{recent_chat.id}} 提供正确值的元素时。

但是当我点击一个聊天项目类块时,它会按预期工作。

【问题讨论】:

  • 你试过不插值吗? ng-click="relocate(recent_chat.id)" 那么你真的不需要插值。还有最近的聊天来自哪里,显示的代码很难理解上下文。

标签: angularjs


【解决方案1】:

需要删除插值。感谢@PSL 在评论中回答

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多