简体   繁体   中英

How to Pass data from controller to mainApp in angularjs

I am implementing meta tags in angularjs using this code :

.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.

In easy way , I want to send dynamic data from homeCtrl to mainApp.

Is there any way to do this in angularjs?

Thanks in advance.

https://docs.angularjs.org/api/ng/service/ $ rootScope(rootScope使用指南和doc) https://www.w3schools.com/angular/angular_scopes.asp (用法示例)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM