Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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 1.3.11-指令未更新html_Angularjs_Angularjs Directive_Typescript_Angularjs Controller - Fatal编程技术网

AngularJs 1.3.11-指令未更新html

AngularJs 1.3.11-指令未更新html,angularjs,angularjs-directive,typescript,angularjs-controller,Angularjs,Angularjs Directive,Typescript,Angularjs Controller,指令模板(Template.html): 这就是所谓的: <section> <somedirective data="model.data"></somedirective> </section> 需要注意的是:在console.log中,范围已成功更改,但ng repeat似乎没有更新。您能帮我吗?显示的代码中没有任何内容会更新数据。这是怎么做到的?预期的结果是什么?问题不清楚。我的

指令模板(Template.html):

这就是所谓的:

 <section>
                <somedirective data="model.data"></somedirective>
           </section>


需要注意的是:在console.log中,范围已成功更改,但ng repeat似乎没有更新。您能帮我吗?

显示的代码中没有任何内容会更新数据。这是怎么做到的?预期的结果是什么?问题不清楚。我的猜测是,您正在从angular外部更改范围,需要通知angular运行数据。控制器正在更新数据,这超出了问题的范围,这就是为什么省略了它。我期望的结果是,每次更新数据时,都会执行ng repeat来更新新数据。我不会从角度之外改变范围。不过,显示的代码中没有任何内容会出现问题。问题不在于代码显示您的模板中缺少关闭标记,但我不确定这是否是问题所在。请查看工作示例。但是,它不是TypeScript
module some.directives {
    'use strict';

    interface MyScope extends ng.IScope {
        data: any;
    }

    class SomeDirective implements ng.IDirective {
        static instance(): ng.IDirective {
            return new SomeDirective;
        }

        restrict = 'E';
        templateUrl = 'Template.html';
        scope = {
            data: '='
        };
        link(scope: MyScope,
            element: ng.IAugmentedJQuery
            ): void {

            scope.$watch('data',() => {
                console.log("changed, new val: ", scope.data);
            });

        }
    }

    angular
        .module('some.directives')
        .directive('somedirective', SomeDirective.instance);
}
 <section>
                <somedirective data="model.data"></somedirective>
           </section>