2

I have an Import/Export functionality.

Here is my cshtml code.

<a href="#" onclick="$('#importPopup').dialog('open');return false;"><img src="import.png" class="btn btn-default btn-xs" title="Importfrom file" data-toggle="tooltip" data-placement="bottom" /></a>

<a href="#" onclick="return false;" ng-click="myViewModel.ExportFile()"><img src="export.png" class="btn btn-default btn-xs" title="Export to file" data-toggle="tooltip" data-placement="bottom" /></a>

<div id="importPopup" title="Import">
    <p><input type="file" id="file_upload" name="file_upload" /></p>
    <p><input type="button" class="_button" value="Import File" ng-click="myViewModel.ImportFile()" /></p>
</div>

Now I have two functions on my typescript code.

public ImportFile() {
    // some codes here
}

public ExportFile() {
    // some codes here
}

My problem here is my ImportFile function is not being hit. I tried to put two breakpoints on both of them, and the ExportFile is working but not the ImportFile.

What did I missed here?

3
  • is there any error in your web console? Commented Nov 17, 2015 at 2:48
  • No, I can't find anything on my console. Commented Nov 17, 2015 at 2:53
  • can you check the genereated js file to see the difference of this two method? Commented Nov 17, 2015 at 2:55

1 Answer 1

3

The trouble is $('#importPopup').dialog('open');. This means that the html is rendered by bootstrap and doesn't go through the angular $compile process. Hence ng-click isn't setup.

Fix

Use something like Angular-BootStrap-Modal : https://angular-ui.github.io/bootstrap/#/modal

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for this! I was able to make it work. I made my importPopup a modal and it is working now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.