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=========================================================
23 export interface IFileOpenerScope extends ng.IScope {
29 onFileUpload(file:any):void;
30 getExtensionsWithDot():string;
33 export class FileOpenerDirective implements ng.IDirective {
35 constructor(private $compile:ng.ICompileService) {
46 template = ():string => {
47 return require('./file-opener.html');
50 link = (scope:IFileOpenerScope, element:any) => {
52 scope.onFileSelect = () => {
53 scope.onFileUpload({file: scope.importFile});
55 // element.html('app/directives/file-opener/file-opener.html');
56 // this.$compile(element.contents())(scope);
59 scope.getExtensionsWithDot = ():string => {
61 _.each(scope.extensions.split(','), function (item) {
62 ret.push("." + item.toString());
69 public static factory = ($compile:ng.ICompileService)=> {
70 return new FileOpenerDirective($compile);
75 FileOpenerDirective.factory.$inject = ['$compile'];