Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

angularjs - Angular events, ng-click, do not work with other libraries Dojo, Knockout, KendoUI, ESRI JSAPI

Continued from this post - Why does ng-click not work?

So I am in the early phases of converting a non-Angular application to Angular. We have not been given the option to do a clean re-write.

This application uses Dojo, require.js, Knockout, ESRI JSAPI, and KendoUI. Using the simple plunker code here:

https://plnkr.co/edit/kK3NmWB9wfOopG7m5MYv?p=preview

$scope.myClick 

does not get called from within this other application.

I have determined that depending on where the Angular app is placed in the index.html file, this affects Angular click and keypress, and probably other events. If I place the app in the HTML before any of the other code, this starts working.

tl;dr Or any ideas on how to isolate Angular code from an existing non-Angular application?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Hope this helps anyone who has a similar problem -

Turns out, this code was what was affecting the angular events:

 <!--ko if: someContext.ready() === true-->
     <div class="ls-rapidReports">
     <div ng-app="myApp">
        <div id="rapidreportCtrl" ng-controller="rrController">
            <button type="button" ng-click="myClick()">hehe</button>
        </div>

    </div>
  </div>
<!--/ko-->

So wrapping Angular components inside Knockout is BAD.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...