简体   繁体   中英

Variables in AngularJS directives with isolated scope

I have directive with an isolated scope.

My scope looks like this:

scope: {
    amount: "=itemsPerPage",
}

My directive:

<list items-per-page="5"></list>

In my directive link function I have:

scope.test = scope.amount;
console.log(scope.test);
console.log(scope.amount);

But the output in console is:

undefined
5

I don't understand why? How does it work? Thanks in advance.

1st one doesn't work because variable name is not correct

convert this

scope.test = scope.amout;

to

scope.test = scope.amount;

JSFIDDLE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM