Reputation: 3736
Hi Guys I am using ng flow in my visual studio web project. I copied all the ng flow javascript file from github.
I have initialised ng flow by using ng-init directive but whenever i am selecting file from my file control i am getting $flow as undefined and therefore i cannot access $scope("flow:fileAdded") event and my files are always null.
my code is given below on how I am using it.
<div class="row">
<div data-flow-init="" data-flow-file-added="!!{png:1,gif:1,jpg:1,jpeg:1}[$file.getExtension()]">
<!--<div data-ng-init="setFlow($flow)"></div>-->
<div class="col-sm-6">
<div class="form-group">
<label for="ll">ll Compay</label>
<!--<span class="btn btn-default" data-flow-btn="">Upload File
<input type="file" multiple="multiple" style="visibility: hidden; position: absolute;">
</span>-->
<span class="btn" flow-btn o>Upload File</span>
</div>
</div>
</div>
above mentioned is my html then In my controller I have got
$scope.AddB = function (fileData) {
$scope.BFactory.Adll(fileData, $flow.files);
}
Any help is appreciated?
Upvotes: 0
Views: 2570
Reputation: 304
If you want to access the $flow object in a parent scope (your $scope is a parent scope of the ng-flow directive's one) you have to use the flow-name attribute, as stated in the documentation: docs
Just make sure you define an object to hold the $flow instance, and you can use it after the container loads
HTML:
<div ng-init="divLoaded()" flow-init flow-name="obj.flow" ... > ... </div>
controller:
$scope.obj = {};
$scope.divLoaded = function() {
// from now on, $scope.obj.flow will be defined
console.log($scope.obj.flow);
}
Upvotes: 1