【问题标题】:skype uri button in angularjs issueangularjs问题中的Skype uri按钮
【发布时间】:2014-11-13 14:34:08
【问题描述】:

我正在尝试使用 AngularJS 将 Skype 按钮添加到我的项目中。代码如下:

HTML:

<script type="text/javascript" src="http://www.skypeassets.com/i/scom/js/skype-uri.js"></script>

<skype-ui id="SkypeButton_Call_1" participants="participants">
                </skype-ui>

AngularJs:

app.directive("skypeUi", function () {
    return {
        restrict: "E",
        template: "<div></div>",
        replace: true,
        scope: {
            participants: "="
        },
        link: function (scope, element, attrs) {
            Skype.ui({
                "name": "chat",
                "element": attrs.id,
                "participants": scope.participants,
                "imageSize": 32
            });
        }
    };
});

但是当我点击它时,它会打开 Skype 窗口,同时显示一条错误消息:“请安装 Skype 应用程序以便拨打电话或发送消息。” Thogh 我已经在我的系统上安装了Skype。你能告诉我为什么会这样显示吗?

【问题讨论】:

  • 你找到解决办法了吗?

标签: javascript angularjs skype skype-uri.js


【解决方案1】:

有同样的问题...问题是skype-uri.js 写得很丑...

它导出全局变量Skype,但它不是具有共享函数的命名空间-它是对象实例,正如我发现的那样-该实例只能正确初始化一个Skype按钮...facepalm...

要添加另一个,您需要再次包含该脚本(以创建该对象的新实例),或者从该实例获取构造函数并使用它创建新的...

这是工作指令:

app.directive("skypeUi", function () {
  var TrueSkype = Skype.constructor;
  return {
    restrict: 'E',
    scope: {
      participants: "="
    },
    link: function (scope, element) {
      var btn = null;
      function removeButton() {
        if (btn) {
          btn.remove();
        }
      }
      scope.$watch('participants', function () {
        removeButton();
        btn = angular.element('<div></div>');
        var id = "SkypeButton_Call_" + Math.random();
        element.append(btn);
        btn.attr('id', id);
        (new TrueSkype()).ui({
          "name": "call",
          "element": id,
          "participants": participants,
          "imageColor": "white",
          "imageSize": 32
        });
      });
      scope.$on('$destroy', removeButton);
    }
  };
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-27
    • 1970-01-01
    • 2015-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多