小编nak*_*kor的帖子

AngularJS指令回调

我想通过标签上的参数将调用发送回指令,然后在指令内适当时调用该方法.例如,单击按钮时,请在父控制器上调用方法.

我有一个简单的plunker它无法正常工作

html文件:

<body ng-controller="ParentController">
    <h1> Method Arguments </h1>
    <h3> open console to view output</h3>
    <hello-world onLoadCallback="myCallback(arg1)"></hello-world>
</body>
Run Code Online (Sandbox Code Playgroud)

javascript文件:

var app = angular.module("app",[]);

function ParentController($scope) {
  $scope.myCallback = function(var1){
    console.log("myCallback", var1);
  }
}
app.directive('helloWorld', function() {
  return {
      restrict: 'AE',
      template: '<h3>Hello World!!</h3>',
      scope:{
            onLoadCallback: '&'
        },
        link: function(scope, element, attrs, dateTimeController) {
            console.log('linked directive, not calling callback')
            scope.onLoadCallback('wtf');

      }
  };
});
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-directive

17
推荐指数
2
解决办法
3万
查看次数

Node.js/Express开源示例网站

有哪些优秀的开源项目能够显示Node.js的高级生产质量,最好使用Express框架?我发现的两件最接近的事情是:

javascript node.js express

13
推荐指数
1
解决办法
9448
查看次数