[英]Sharing $scope data between angular js and non angular js
In the AngularJS, $scope.mydata
contains some data with in the controller. 在AngularJS中,
$scope.mydata
包含控制器中的一些数据。 I'm using JSP (normal JSP page) with out any AngularJS functionality,But I want the data with in the scope variable (mydata) which contains in the controller. 我正在使用没有任何AngularJS功能的JSP(普通JSP页面),但是我希望数据包含在控制器中包含的范围变量(mydata)中。 How can I retrieve the data with in the scope variable in my jsp page.
如何在jsp页面的scope变量中检索数据。 Can anybody sugest this..
任何人都可以对此提出建议。
I think you can make a variable in top of app.js in angular stater project. 我认为您可以在angular stater项目的app.js顶部创建一个变量。 Just make it clear may this sample code help you base on angular tabs starter project:
请清楚说明一下,此示例代码是否可以帮助您基于Angle Tabs Starter项目:
// in app.js
var myShareData;
...
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
// in controller.js
...
.controller('FriendsCtrl', function($scope, Friends) {
$scope.friends = Friends.all();
myShareData = Friends.all();
// or
// myShareData = $scope.friends;
})
Now you can use myShareData
at any where on your non angular js. 现在,您可以在非角度js上的任何位置使用
myShareData
。 Off course you need check myShareData
has value or not before you can use it. 当然,您需要检查
myShareData
是否有价值,然后才能使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.