[英]How to Pass data from controller to mainApp in angularjs
I am implementing meta tags in angularjs using this code : 我正在使用此代码在angularjs中实现元标记:
.state('home', {
url: "/home/",
metaTags: {
title: 'abc',
description: 'xyz',
keywords: 'xyz',
properties: {
'og:title': abc'
}
},
views : {
"" : {
templateUrl:"/home/home.html",
controller: 'homeCtrl',
controllerAs:'vm',
}
},
resolve: {
loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load('home'); // Resolve promise and load before view
}]
}
})
It is working fine because I fixed the meta tags but, I want to send dynamic data from a controller to mainApp. 之所以能正常工作,是因为我修复了meta标签,但是我想将动态数据从控制器发送到mainApp。
In easy way , I want to send dynamic data from homeCtrl to mainApp. 我想以简单的方式将动态数据从homeCtrl发送到mainApp。
Is there any way to do this in angularjs? 有没有办法在angularjs中做到这一点?
Thanks in advance. 提前致谢。
https://docs.angularjs.org/api/ng/service/ $ rootScope(rootScope使用指南和doc) https://www.w3schools.com/angular/angular_scopes.asp (用法示例)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.