2016-09-02 68 views
0

我正在嘗試使用RatchetJS(移動框架,而不是websocket服務器,即goratchet.com !!)和AngularJS(v1.5.8)構建應用程序。我的問題涉及項目組織,路由和頁面加載。與Ratchet.js集成AngularJS

如果我想要棘輪過渡與角度js路由和控制器很好地發揮,應該如何處理路由?這是我到目前爲止。

的index.html

<!DOCTYPE html> 
<html lang="en" ng-app="Application"> 
<head> 
    <meta charset="utf-8"> 
    <title>MyApplication</title> 
    <base href="/"> 
    <!-- Sets initial viewport load and disables zooming --> 
    <meta name="viewport" content="initial-scale=1, maximum-scale=1"> 

    <!-- Makes your prototype chrome-less once bookmarked to your phone's home screen --> 
    <meta name="apple-mobile-web-app-capable" content="yes"> 
    <meta name="apple-mobile-web-app-status-bar-style" content="black"> 

    <!-- Include the compiled Ratchet CSS --> 
    <link href="css/ratchet.css" rel="stylesheet"> 
    <!-- <link href="css/ratchet-theme-ios.css" rel="stylesheet"> --> 
    <!-- <link href="css/ratchet-theme-android.css" rel="stylesheet"> --> 

    <!-- Include the compiled Ratchet JS --> 
    <script src="js/ratchet.min.js"></script> 
    <script src="js/angular.min.js"></script> 
    <script src="js/angular-route.min.js"></script> 
    <script src="app/app.js"></script> 
</head> 
<body> 
    <div class="view" ng-view></div> 
</body> 
</html> 

角JS應用文件。

'use strict'; 
(function() { 

    var Application = angular.module('Application', ['ngRoute']); 

    Application.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { 

      $routeProvider 
       .when('/', { 
        controller: 'DefaultController', 
        templateUrl: 'pages/home.html', 
       }) 
       .when('/pages/chat.html', { 
        controller: 'ChatController', 
        templateUrl: '/pages/chat.html', 
       }) 
       .otherwise({ redirectUrl: '/' }) 
      ; 

      $locationProvider.html5Mode(true); 
    }]); 

    Application.controller('DefaultController', ['$scope', '$route', function($scope, $route) { 
     $scope.title = "Grettings"; 
    }]); 

    Application.controller('ChatController', ['$scope', function($scope) { 
     $scope.title = "Chat view"; 
    }]); 

})(); 

也有/pages/...文件夾(home.htmlchat.html)兩個文件。在Home.html中包含一個鏈接看起來像:

<a data-ignore="push" href="/pages/chat.html">Go to chat</a> 

如果我使用data-ignore="push"頁面被加載,而是通過角(所以沒有棘輪轉換沒有它,當然,頁面得到由棘輪加載,但AngularJS沒有趕上路線和控制器從來不叫......

提供我想使用的轉換棘輪。我應該如何處理我的建築/路由?

回答

0

棘輪並不意味着過渡或你指的是

這意味着作爲PHP的WebSocket你遇到的問題是客戶端的頁面加載,所以嘗試添加更多關於你的角度安裝的信息。

+0

http://goratchet.com/更是一個CSS js/css UI/UX框架...與websockets無關..或者?它確實提供了轉換。 –