0

I am creating a variable rejecting another one, in "First.js" file:

var nosubs = _.reject(subs, function (bi) { return bi.ParentBoardbookItemId === '0'; });

Is it possible to call this variable (nosubs) to "Second.js" file? How can I do that?

Notice that i a

Thank you in advance!

2
  • Can you tell me exactly what are you going to achieve by referring variable? This will help me to give a better answer Commented Apr 27, 2016 at 13:31
  • The above is a Javascript with underscore. Do you want to just use the variable nosubs from another file or you want to use angular? Commented Apr 27, 2016 at 13:40

2 Answers 2

1

There is tons of way of doing it. The best in angular is to not use variables. But to store your data in a service.

// simplified version of defining the service
app.service("myService", function(){
    this.setData = function(data){
        this.data = data;
    };
    this.getData = function(){
         return this.data;
    };
    return this;
});
// now you just have to inject it in your controllers/run blocks and you can use myService.data.

Another solution would be to store it in the $rootScope.

If you want/need something else we'll need more information.

Sign up to request clarification or add additional context in comments.

Comments

0

You can store varible in rootscope to access in other files.

$rootScope.nosubs = _.reject(subs, function (bi) { return bi.ParentBoardbookItemId === '0'; });

Comments

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.