Angularjs:如何将范围值传递给指令

时间:2015-02-26 13:22:47

标签: angularjs angularjs-directive angularjs-scope

我已经写了一个指令来显示记录的通用模板。 我试图捕捉新设置$scope的值,但每次打印我最初定义的$scope

这是我的工作方式

$scope.commonExamTemplate    =false;
$scope.examReportHolder      =[];
$scope.examReportHolderCode  =0;

$scope.examSchedule=function(forDay){

angService.getfromRemote('exam/'+forDay)
      .success(function(response){

            console.log(response.success);    
            $scope.commonExamTemplate    =true;
            $scope.examReportHolder      =response.success;
            $scope.examReportHolderCode  =200;
     })
      .error(function(response){

            $scope.commonExamTemplate    =false;
            $scope.examReportHolder      =[];
            $scope.examReportHolderCode  =502;
            toaster.pop('error','Connection Issue','Bad Network Connection.');
      });

}




}])
.directive('examSheet',function(){

    return{
        templateUrl :'templates/exam/commonexamlist.html',  //i am //loding my template now here in this template i want to print the value of //`$scope.examReportHolder`,which contineously showing me [] as i defined it //initially
        controller  :'examController',
        value       :examReportHolder

    }

和我的HTML

<div ng-if="examReportHolderCode==200" exam-sheet>here i am </div>

和我的commonexamlist.html

 <div class="row  text-center">
                  {{examReportHolder}}
                  {{valuee}}
                  </div>

0 个答案:

没有答案