Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

how to initialize value inside run block in angular.js

directives.value("value1","test1");

directives.run(function(value1){
    value1="test2";
})

Is this possible

share|improve this question

If you are using a primitive as the value, you will only get a copy of that injected into the run function and you will not be able to replace the original one.

Use an object instead:

directives.value("value1", { something: "test1" });

directives.run(function(value1){
    value1.something = "test2";
})
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.