2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 import * as _ from "lodash";
24 export interface IFileOpenerScope extends ng.IScope {
30 onFileUpload(file:any):void;
31 getExtensionsWithDot():string;
34 export class FileOpenerDirective implements ng.IDirective {
36 constructor(private $compile:ng.ICompileService) {
47 template = ():string => {
48 return require('./file-opener.html');
51 link = (scope:IFileOpenerScope, element:any) => {
53 scope.onFileSelect = () => {
54 scope.onFileUpload({file: scope.importFile});
56 // element.html('app/directives/file-opener/file-opener.html');
57 // this.$compile(element.contents())(scope);
60 scope.getExtensionsWithDot = ():string => {
62 _.each(scope.extensions.split(','), function (item) {
63 ret.push("." + item.toString());
70 public static factory = ($compile:ng.ICompileService)=> {
71 return new FileOpenerDirective($compile);
76 FileOpenerDirective.factory.$inject = ['$compile'];