相关疑难解决方法(0)

如果我有jQuery背景,"在AngularJS中思考"?

假设我熟悉在jQuery中开发客户端应用程序,但现在我想开始使用AngularJS.你能描述一下必要的范式转变吗?以下是一些可能有助于您确定答案的问题:

  • 如何以不同方式构建和设计客户端Web应用程序?最大的区别是什么?
  • 我应该停止做什么/使用什么; 我应该开始做什么/使用呢?
  • 是否存在任何服务器端注意事项/限制?

我不是在寻找jQuery和之间的详细比较AngularJS.

javascript jquery angularjs

4518
推荐指数
15
解决办法
81万
查看次数

AngularJS - 将函数传递给指令

我有一个例子angularJS

<div ng-controller="testCtrl">

<test color1="color1" updateFn="updateFn()"></test>
</div>
 <script>
  angular.module('dr', [])
.controller("testCtrl", function($scope) {
    $scope.color1 = "color";
    $scope.updateFn = function() {
        alert('123');
    }
})
.directive('test', function() {
    return {
        restrict: 'E',
        scope: {color1: '=',
                updateFn: '&'},
        template: "<button ng-click='updateFn()'>Click</button>",
        replace: true,
        link: function(scope, elm, attrs) { 
        }
    }
});

</script>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

我想当我点击按钮时,会出现警告框,但没有任何显示.

谁能帮我?

angularjs

156
推荐指数
5
解决办法
14万
查看次数

标签 统计

angularjs ×2

javascript ×1

jquery ×1