Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJs:从指令到控制器的变量_Angularjs_Angularjs Directive_Angularjs Scope - Fatal编程技术网

AngularJs:从指令到控制器的变量

AngularJs:从指令到控制器的变量,angularjs,angularjs-directive,angularjs-scope,Angularjs,Angularjs Directive,Angularjs Scope,如何将指令中的变量itemSelect传递给控制器 mDirective.directive('directive', function() { return { restrict: 'A', scope: { options: "=" }, templateUrl: '', link: function(scope, element, attrs) {

如何将指令中的变量itemSelect传递给控制器

mDirective.directive('directive', function() {
    return {
        restrict: 'A',
        scope: {
            options: "="
        },
        templateUrl: '',

        link: function(scope, element, attrs) {  
                .........               
             $(element).find('.typeY').on('change', function() {
                var itemSelect =   $(element).find('.typeY').val();
            });
        } ,

    };
});
差不多

mDirective.directive('directive', function() {
    return {
        restrict: 'A',
        scope: {
            options: "=",
            selected:"=",
        },
        templateUrl: '',

        link: function(scope, element, attrs) {  
                .........               
            $(element).find('.typeY').on('change', function() {
                scope.$apply(function() {
                  scope.selected=value;  // value from the element
                });
            });
        } ,

    };
});
在html级别


你可以解释更多。