$ rootScope的全局函数(angularJS)

时间:2018-06-16 22:23:26

标签: angularjs

我必须制作类似全局功能的东西,但我在某处犯错,任何人都可以看到并帮助我解决这个问题:

 <div>
 <p class="comment-name">{{getName}}</p>
            <p class="comment-mail">{{getMail}}</p>
        <div class="comment_content">
            <p class="comment-com">{{getComm}}</p>
            <button class="post-comm" ng-click="postCom()">Post</button>
 
    </div>

AngularJS:

myApp.run(function ($rootScope) {
     $rootScope.postCom = function () {
         $rootScope.getName = $rootScope.name;
         $rootScope.getMail = $rootScope.mail;
         $rootScope.getComm = $rootScope.comment;
     };

 });

0 个答案:

没有答案