を助け 希望は私は、このソリューションは、(angular.element()にいる間、ここで私たちは、角度サービス$window
を使用しているためangular.element(....).scope()
を使用 他のソリューションよりも優れている、あなたの場合には、検索し、試した後、この解決策を思いつきました.scope)は、いくつかの角度モード、check thisで無効にすることができます。
CBR_XML_Daily_Ru = function(data) {
angular.element("#controllerDivId").controller().angularJsonpCallBackDefindInController(data);
};
var myApp = angular.module('myApp', []).controller('myCtrl', myCtrl);
function myCtrl($scope, $http,$window) {
var self = this;
$http.jsonp('https://www.cbr-xml-daily.ru/daily_jsonp.js?callback=JSON_CALLBACK');
self.angularJsonpCallBackDefindInController = function (data) {
self.divForCharCode = data.Valute.EUR.CharCode;
};
}
これはHTML(あなたが第二の溶液を使用するためにjqueryのを含める必要がある)
です:あなたもjqueryの「スコープ」からコントローラ内の関数を実行するためのこの方法を使用することができます
CBR_XML_Daily_Ru = function(data) {
window.angularJsonpCallBackDefindInController(data);
};
var myApp = angular.module('myApp', []).controller('myCtrl', myCtrl);
function myCtrl($scope, $http,$window) {
var self = this;
$http.jsonp('https://www.cbr-xml-daily.ru/daily_jsonp.js?callback=JSON_CALLBACK');
$window.angularJsonpCallBackDefindInController = function (data) {
//u can do anything here, you are in the controller, and in the same time this function in the window object and get called from anywhere even in jquery
self.divForCharCode = data.Valute.EUR.CharCode;
};
}
<html>
<head>
<script src="jquery-3.1.1.min.js"></script>
<script src="angular.min.js"></script>
<!--<link rel="stylesheet" href="style.css" />-->
<script src="jsnopstuff.js"></script>
</head>
<body>
<div id="controllerDivId" ng-controller='myCtrl as ctrl' ng-app='myApp'>
<input type=text ng-model='ctrl.divForCharCode'>
<div id='div1'></div>
</div>
</body>
</html>
私はあなたがここを見なければならないと思う[類似の場合質問](http://stackoverflow.com/questions/12066002/parsing-jsonp-http-jsonp-response-in-angular-js) –