This is my directive file code
function imageUploadDirective(fileReader, rootScope) {
function imageUploadLinker(scope, elem, attr) {
    scope.$inputFileElement = elem.find(":file");
    scope.$inputFileElement.bind("change", function (e) {
        rootScope.invalid_image_msg = "";
        e.stopPropagation();
        var files = e.target.files === undefined ? (e.target && e.target.value ? [{
                name: e.target.value.replace(/^.+\\/, '')
            }] : []) : e.target.files;
        console.log("files: ", files);
        console.log("FILE ZERO INDEX");
        console.log(files[0]);
        if (files.length === 0 || files.length > 1 || !fileReader.isImageFile(files[0])) {
            if (!fileReader.isImageFile(files[0])) {
                rootScope.invalid_image_msg = "IT's Not an Image, Please Select Valid Format of Image";
            } else {
                rootScope.invalid_image_msg = "Please Select an Valid Image";
            }
            rootScope.is_image_valid = false;
            console.log("reset");
            scope.reset();
            return;
        }
        scope.fileName = files[0];
        fileReader
                .readAsDataUrl(scope.fileName, scope)
                .then(function (result) {
                    rootScope.userInfo.imageSrc = result;
                });
    });
}
return {
    restrict: "EA",
    templateUrl: "/user/imageUploadTemplate",
    scope: {
        name: "@",
        alt: "@",
        selectBtnTitle: "@",
        changeBtnTitle: "@",
        removeBtnTitle: "@",
        noImage: "@"
    },
    controller: "lugbeeUserSPACtrl",
    link: imageUploadLinker
};
}
imageUploadDirective.$inject = ["fileReader", "$rootScope"];
angular
    .module("lugbeeUserSPA")
    .directive("imageUpload", imageUploadDirective);
This is my template html file code
<div class="fileinput">
<div data-text="{{noImage}}" class="thumbnail image-upload-preview">
    <img ng-show="hostInfo.imageSrc" ng-src="{{hostInfo.profile_image_path}}" alt="{{imageSrc ? alt : ''}}">
</div>
<div>
    <span class="btn btn-default btn-file">
        <span ng-if="!fileName" ng-click="openFileSelector()">{{:: selectBtnTitle}}</span>
        <span ng-if="!!fileName" ng-click="openFileSelector()">{{:: changeBtnTitle}}</span>
        <input type="file" class="inputfile" name="{{:: name}}" id="{{:: name}}">
    </span>
    <a href="#" class="btn btn-default" ng-click="reset()" ng-if="!!fileName">{{:: removeBtnTitle}}</a>
</div>
How to remove controller option from the above code and also how can I replace scope option object with controller scope variable. please help me to solve this problem because the controller onload function calls two times because of controller option that's why I want this.
 
    