如何在Angularjs中调用函数? var-app=angular.module('myApp',[]); app.controller('myCtrl',函数($scope,$http) { $http.get(“http://www.adhr.adnacgroup.com/ADHRM/companyJson.php") .然后(功能(响应) {$scope.names=$scope.names=response.data.service;}); 函数getInfo(){ $http.post('getTask1.php').success(函数(数据){ $scope.details=数据; }) } }); var-app=angular.module('myApp',[]); app.controller('myCtrl',函数($scope,$http) { $http.get(“http://www.adhr.adnacgroup.com/ADHRM/companyJson.php") .然后(功能(响应) {$scope.names=$scope.names=response.data.service;}); 函数getInfo(){ $http.post('getTask2.php').success(函数(数据){ $scope.details=数据; }) } }); var-app=angular.module('myApp',[]); app.controller('myCtrl',函数($scope,$http) { $http.get(“http://www.adhr.adnacgroup.com/ADHRM/companyJson.php") .然后(功能(响应) {$scope.names=$scope.names=response.data.service;}); 函数getInfo(){ $http.post('getTask3.php').success(函数(数据){ $scope.details=数据; }) } });

如何在Angularjs中调用函数? var-app=angular.module('myApp',[]); app.controller('myCtrl',函数($scope,$http) { $http.get(“http://www.adhr.adnacgroup.com/ADHRM/companyJson.php") .然后(功能(响应) {$scope.names=$scope.names=response.data.service;}); 函数getInfo(){ $http.post('getTask1.php').success(函数(数据){ $scope.details=数据; }) } }); var-app=angular.module('myApp',[]); app.controller('myCtrl',函数($scope,$http) { $http.get(“http://www.adhr.adnacgroup.com/ADHRM/companyJson.php") .然后(功能(响应) {$scope.names=$scope.names=response.data.service;}); 函数getInfo(){ $http.post('getTask2.php').success(函数(数据){ $scope.details=数据; }) } }); var-app=angular.module('myApp',[]); app.controller('myCtrl',函数($scope,$http) { $http.get(“http://www.adhr.adnacgroup.com/ADHRM/companyJson.php") .然后(功能(响应) {$scope.names=$scope.names=response.data.service;}); 函数getInfo(){ $http.post('getTask3.php').success(函数(数据){ $scope.details=数据; }) } });,php,angularjs,function,Php,Angularjs,Function,我在3个不同的页面上有3个脚本,使用相同的ng应用程序和ng控制器 下面的代码是我为脚本1创建的gettask1.php以及我为所有脚本创建的类似页面,用于从不同的表中获取记录。但问题是,我只能检索所有选项卡中的最后一个脚本数据。我是angularjs的新手,请提前帮我表达同样的感谢 <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope, $http

我在3个不同的页面上有3个脚本,使用相同的ng应用程序和ng控制器

下面的代码是我为脚本1创建的gettask1.php以及我为所有脚本创建的类似页面,用于从不同的表中获取记录。但问题是,我只能检索所有选项卡中的最后一个脚本数据。我是angularjs的新手,请提前帮我表达同样的感谢

  <script>
  var app = angular.module('myApp', []);
  app.controller('myCtrl', function($scope, $http) 
  {
    $http.get("http://www.adhr.adnacgroup.com/ADHRM/companyJson.php")
    .then(function(response) 
    {$scope.names = $scope.names = response.data.service;});    
    function getInfo(){
      $http.post('getTask1.php').success(function(data){
         $scope.details = data;
      })
    }      
  });
</script>

<script>
  var app = angular.module('myApp', []);
  app.controller('myCtrl', function($scope, $http) 
  {
    $http.get("http://www.adhr.adnacgroup.com/ADHRM/companyJson.php")
    .then(function(response) 
    {$scope.names = $scope.names = response.data.service;});    
    function getInfo(){
      $http.post('getTask2.php').success(function(data){
         $scope.details = data;
      })
    }      
  });
</script>

<script>
  var app = angular.module('myApp', []);
  app.controller('myCtrl', function($scope, $http) 
  {
    $http.get("http://www.adhr.adnacgroup.com/ADHRM/companyJson.php")
    .then(function(response) 
    {$scope.names = $scope.names = response.data.service;});    
    function getInfo(){
      $http.post('getTask3.php').success(function(data){
         $scope.details = data;
      })
    }      
  });
</script>

您可以执行以下操作:

<?php
ob_start();
session_start();
include"includes/dbconfig.php";
$org_id=$_SESSION['org_id'];
if(!isset($_SESSION['org_id'])){
header("Location:index.php");
}
getInfo();
$query = "SELECT * from `offer_letter` ORDER BY `offer_id` ASC";
$result = mysql_query($query);
$arr = array();
if(mysql_num_rows($result) != 0) {
while($row = mysql_fetch_assoc($result)) {
$arr[] = $row;
}
}
echo $json_info = json_encode($arr);
?>
您可以从模板中调用example()

     (function(angular) {
        angular.module('controllerExample', [])
          .controller('myctrl', ['$scope', myctrl]);
        function myctrl($scope) {     

    $scope.example=function example(){

         //your code will be  here 
       }

    function example2(){
      //do your code. You can call this function only in this controller.
    }
  example2();

    }
})(window.angular);