signalr客户端没有填充angularjs指令

时间:2017-05-06 17:04:16

标签: angularjs angularjs-directive signals

我有一个将使用SignalR的angularjs指令。

(function(){
  "use strict";

        angular.module('docsSimpleDirective', [])
        .controller('Controller', ['$scope', function($scope) {
                var hub = $.connection.realtimeFult;

                $.connection.hub.url = "http://localhost:39858/signalr";
                $.connection.hub.start();

                hub.client.faultOccured = function (location) {
                    console.log(location);
                };
        }])
        .directive('myCustomer', function() {
          return {
            template: 'Name: {{customer.name}} Address: {{customer.address}}'
          };
        });      
})();

这不会写任何浏览器控制台。

但是如果我将signalR代码移出它写的指令。

(function(){
  "use strict";

        var hub = $.connection.realtimeFult;

        $.connection.hub.url = "http://localhost:39858/signalr";
        $.connection.hub.start();

        hub.client.faultOccured = function (location) {
            console.log(location);
        };

        angular.module('docsSimpleDirective', [])
        .controller('Controller', ['$scope', function($scope) {

        }])
        .directive('myCustomer', function() {
          return {
            template: 'Name: {{customer.name}} Address: {{customer.address}}'
          };
        });      
})();

此代码编写浏览器控制台日志。

这个有趣问题的原因是什么?

0 个答案:

没有答案