0
<input type="file" my-file="angularVar" my-file-type="MY_STRING" />

angularVar is just a normal var on the scope, that I want to bind task-file to.

How do I make my-file-type accept a normal string though? Just something to pass through to the directive?

I have this:

scope: {
    taskFile: '=',
    taskFileType: '='
},

But what I want in my "link" logic is something like:

if (scope.myFileType != null && scope.myFileType == "MY_STRING") {
    // do something
}

How can I do that? Without it trying to bind to some non-existant var called MY_STRING.

Cheers

1
  • if you want to pass hardcoded value from the attribute then you could easily achieve by having attrs.myFileType inside your directive..no need to include that in your directive isolated scope.. Commented Nov 9, 2015 at 7:18

2 Answers 2

1

Declare a variable in scope with @

Like this

scope : {
  myFileType:'@'
}

Then in html

<input type="file" my-file="angularVar" my-file-type="'MY_STRING'" />
Sign up to request clarification or add additional context in comments.

2 Comments

I hope that should be single quote instead of tilde key.
@BhojendraNepal: that was backtick, not tilde. :)
0

Use a single quote to denote it as a string and use @ binding instead of =:

 my-file-type="'MY_STRING'"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.