Answer the question
In order to leave comments, you need to log in
How to pass data from a controller to a directive?
Good evening)
Please tell me how (in the first angular) to pass a variable from the controller to the directive using the syntax controller as
For example:
angular
.module('test', [])
.controller('first', function () {
this.somevar = 'Lorem'; // -> Эту переменную
})
.directive('one', function () {
restrict: 'A',
link: function () {
console.log(somevar); // <- Получить здесь
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question