Learn
We used app.directive
to create a new directive named 'installApp'
.
- The directive contains the three options
restrict
,scope
, andtemplateUrl
that we saw before in the'appInfo'
directive. - It also contains a fourth option
link
. Thelink
is used to create interactive directives that respond to user actions.
The link function takes three inputs:
scope
refers to the directive’s scope. Any new properties attached to$scope
will become available to use in the directive’s template.element
refers to the directive’s HTML element.attrs
contains the element’s attributes.
Inside the link
function, there are two properties buttonText
and installed
, and the function download()
. We’ll use these in the directive’s template next.
Instructions
1.
Next, write the directive’s template:
In the new file js/directives/installApp.html. Type in the following HTML:
<button class="btn btn-active" ng-click="download()"> {{ buttonText }} </button>
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.