dgf лет назад: 8
Родитель
Сommit
834c2a248d

+ 0 - 11
talkview/src/js/controller/messageController.js

@@ -26,17 +26,6 @@ angular.module('appMessage').controller('MessageController', ['$scope', '$filter
             $scope.sendmessages.push(msg);
             $scope.scrollHide();
         };
-        $scope.OpenFile = function(item) {
-            // var item = { fileName: file };
-            console.log("1111111111");
-            return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenFile', JSON.stringify(item), $scope);
-        };
-        $scope.OpenDirectory = function(item) {
-            // var item = { fileName: file };
-            console.log(JSON.stringify(item));
-            return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenDirectory', JSON.stringify(item), $scope);
-
-        };
 
         $scope.showHistoryMessage = function(jsonStr) {
             console.log(jsonStr);

+ 27 - 20
talkview/src/js/directive/historymessages.js

@@ -5,11 +5,12 @@
         .module('appMessage')
         .directive('ngHistoryMsg', HistoryMsg);
 
-    HistoryMsg.inject = ['$location', '$anchorScroll', '$filter'];
+    HistoryMsg.inject = ['$location', '$anchorScroll', '$filter', '$compile'];
 
-    function HistoryMsg($location, $anchorScroll, $filter) {
+    function HistoryMsg($location, $anchorScroll, $filter, $compile) {
         var directive = {
             link: link,
+            controller: ControllerController,
             restrict: 'A',
             scope: {
                 msg: '=ngHistoryMsg',
@@ -56,16 +57,16 @@
                 return $filter("date")(item.ts, "yyyy-MM-dd HH:mm:ss");
             };
 
-            scope.OpenFile = function(item) {
-                // var item = { fileName: file };
-                return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenFile', JSON.stringify(item), scope);
-            };
-            scope.OpenDirectory = function(item) {
-                // var item = { fileName: file };
-                console.log(JSON.stringify(item));
-                return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenDirectory', JSON.stringify(item), scope);
+            // scope.OpenFile = function(item) {
+            //     // var item = { fileName: file };
+            //     return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenFile', JSON.stringify(item), scope);
+            // };
+            // scope.OpenDirectory = function(item) {
+            //     // var item = { fileName: file };
+            //     console.log(JSON.stringify(item));
+            //     return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenDirectory', JSON.stringify(item), scope);
 
-            };
+            // };
             var replaceSystemFace = function(content) {
                 //匹配表情
                 var g = (/\/\:([\w]+)/).exec(content);
@@ -177,8 +178,8 @@
                     '<span>大小:' + getFileSize(content) + '</span>' +
                     '<div class="p-t-sm text-right">' +
                     '<span id="transinfo"><span style="color:green;" class="glyphicon glyphicon-ok"></span><span>传输完成</span></span>' +
-                    '<a class="text-primary" role="button"><span ng-click="OpenFile(item.content)">打开</span></a>&nbsp&nbsp' +
-                    '<a class="text-primary" role="button"><span ng-click="OpenDirectory(item.content)">打开文件夹</span></a>' +
+                    '<a class="text-primary" role="button"><span ng-click="OpenFile(msg.content)">打开</span></a>&nbsp&nbsp' +
+                    '<a class="text-primary" role="button"><span ng-click="OpenDirectory(msg.content)">打开文件夹</span></a>' +
                     '</div>' +
                     '</div>';
             } else if (scope.msg.contentType == 4) {
@@ -213,23 +214,29 @@
                     '<div class="text-point"></div>' + html +
                     '</div></div></div>';
             }
-            angular.element("#loadmore").prepend(html_g);
+
+            var compileFn = $compile(html_g);
+            // 传入scope,得到编译好的dom对象(已封装为jqlite对象)
+            // 也可以用$scope.$new()创建继承的作用域
+            var $dom = compileFn(scope);
+            // 添加到文档中
+            angular.element("#loadmore").prepend($dom);
             console.log(html_g);
             if (scope.count) {
                 message.addEventListener('load', gotoBottom());
             }
         }
-    }
+    };
     /* @ngInject */
-    function ControllerController(scope) {
-        scope.OpenFile = function(item) {
+    function ControllerController($scope) {
+        $scope.OpenFile = function(item) {
             // var item = { fileName: file };
-            return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenFile', JSON.stringify(item), scope);
+            return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenFile', JSON.stringify(item), $scope);
         };
-        scope.OpenDirectory = function(item) {
+        $scope.OpenDirectory = function(item) {
             // var item = { fileName: file };
             console.log(JSON.stringify(item));
-            return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenDirectory', JSON.stringify(item), scope);
+            return lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'OpenDirectory', JSON.stringify(item), $scope);
 
         };
     }