0

I have no idea why the script tag can't working, here is the reproduce step: ionic cli 1.3.10

1.ionic start mytab

2.add following to templates/chat-detail.htm in ion-content

<p id="demo"></p>

<script>
var txt="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
document.getElementById("demo").innerHTML = txt.length;
</script>

3.ionic serve --lab

4.navigate to chat detail page,the script couldn't work

why is that happened?

user1349923
  • 763
  • 1
  • 7
  • 24
  • 2
    What are the errors in the browser's console? Also, can you reproduce in a jsfiddle? – devqon Feb 19 '15 at 08:17
  • there is no error in the browser's console, jsfiddle doesn't have ionic framework? – user1349923 Feb 19 '15 at 11:49
  • You can include external libraries in jsfiddle. Try this Ionic starter template: http://jsfiddle.net/Chofoteddy/y7D4r/ – devqon Feb 19 '15 at 11:50
  • The angularjs template doesn't support – user1349923 Feb 19 '15 at 12:37

1 Answers1

0

try put the js to the controllers, something like:

$scope.$on("$ionicView.loaded", function() {
  document.getElementById("demo").innerHTML = txt.length;
}
zjx
  • 56
  • 5