0
var app = angular.module("myApp",['ui.router','flow']);
    app.config(['flowFactoryProvider', function (flowFactoryProvider) {
        flowFactoryProvider.defaults = {
        target: 'upload.php?type=1',
        testChunks:false,
        singleFile: true,
        permanentErrors: [404, 500, 501],
        maxChunkRetries: 1,
        chunkRetryInterval: 5000,
        simultaneousUploads: 4
    };  
}]);

Above code is working perfectly...

I just want to change target dynamically from $scope variable

i think it should be something like

var app = angular.module("myApp",['ui.router','flow']);
    app.config(['flowFactoryProvider', function (flowFactoryProvider) {
        flowFactoryProvider.defaults = {
        target: 'upload.php?type=' + $scope.vtype,
        testChunks:false,
        singleFile: true,
        permanentErrors: [404, 500, 501],
        maxChunkRetries: 1,
        chunkRetryInterval: 5000,
        simultaneousUploads: 4
    };  
}]);

Thanks for any help.

1 Answer 1

2

Two possible ways I can think of:

Import $rootScope and set it there:

var app = angular.module("myApp",['ui.router','flow']);
    app.config(['flowFactoryProvider', function (flowFactoryProvider, $rootScope) {
        flowFactoryProvider.defaults = {
            target: 'upload.php?type=' + $rootScope.vtype,
            testChunks:false,
            singleFile: true,
            permanentErrors: [404, 500, 501],
            maxChunkRetries: 1,
            chunkRetryInterval: 5000,
            simultaneousUploads: 4
        };  
    }
]);

and in some controller, you can set it as

$rootScope.vtype = something;

OR you could write a get/set method inside the provider which would allow you to change a local value.

var app = angular.module("myApp",['ui.router','flow']);
    app.config(['flowFactoryProvider', function (flowFactoryProvider) {

        var someLocalValue = 1; // default value

        flowFactoryProvider.defaults = {
            target: 'upload.php?type=' + someLocalValue,
            testChunks:false,
            singleFile: true,
            permanentErrors: [404, 500, 501],
            maxChunkRetries: 1,
            chunkRetryInterval: 5000,
            simultaneousUploads: 4
        };  
        flowFactoryProvider.getSomeLocalValue = function(){
            return someLocalValue;
        };
        flowFactoryProvider.setSomeLocalValue = function(input){
            flowFactoryProvider.defaults.target = 'upload.php?type=' + input;
            someLocalValue = input;
        };
    }
]);
Sign up to request clarification or add additional context in comments.

6 Comments

hey thanks many thanks for the code buddy.. will i be able to set it from my html page? and if yes then please guide me how?
no, you will set it in the javascript, not the html.
The second approach is correct. Avoid $rootScope as it sets global state.
so how will i be able to set the value from controller?
what you really could use is a service which stores data for use by other services, then you can set defaults there and change it as well if needed. to set it in your controller, you need to inject the object into your controller, and run the set method.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.