组合不同的Javascript框架有缺点吗?

组合不同的Javascript框架有缺点吗?,javascript,php,jquery,ajax,angularjs,Javascript,Php,Jquery,Ajax,Angularjs,我打算将Angular用于一些前端内容,但将其用于带有PHP文件的Ajax时,代码会比jquery更加冗长 比如说 app.controller('sign_up', function ($scope, $http) { /* * This method will be called on click event of button. * Here we will read the email and password value and call our PHP fil

我打算将Angular用于一些前端内容,但将其用于带有PHP文件的Ajax时,代码会比jquery更加冗长

比如说

app.controller('sign_up', function ($scope, $http) {
    /*
    * This method will be called on click event of button.
    * Here we will read the email and password value and call our PHP file.
    */
    $scope.check_credentials = function () {

        document.getElementById("message").textContent = "";

        var request = $http({
            method: "post",
            url: window.location.href + "login.php",
            data: {
                email: $scope.email,
                pass: $scope.password
            },
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        });
        /* Check whether the HTTP Request is successful or not. */
        request.success(function (data) {
            document.getElementById("message").textContent = "You have login successfully with email "+data;
        });
    }
});
然后你需要解码json等等。所以,如果我使用jquery来处理AJAX,使用angular来处理其他事情,就不会有任何冲突或任何事情了


感谢您可能不知道,但是Angular在JQuery库上运行(如果未指定JQuery导入,则默认使用JQuery的子集调用jQLite),因此您可以轻松导入JQuery库并将其用于ajax调用

我是Angular、JQuery、Bootstrap、AngularUI和


它们都有各自的目的。AngularUI非常流行,使用AngularUI甚至更好。与Bootstrap混合,我发现我的代码更少,我的网站看起来更好。JQuery,这样我就可以查询DOM,我使用jinqJs来查询javaScript数据,就像使用类似SQL的表达式一样。我在一起使用所有框架时没有遇到任何问题。本例中的服务是PHP,但当然也可以是.NETWebAPI。只要数据格式是JSON(例如使用预定义的结构),那么前端和后端使用的内容就不会相互影响。

请看一看AngularJS并不能完全取代jQuery,但在大多数情况下,在不直接使用jQuery的情况下,有一种不同的方法来做同样的事情。您的问题似乎不完整。您应该显示代码的等效jquery版本。我质疑jquery版本将明显减少冗长的断言。我可以补充一点,angular中不需要使用“document.getElementById”。您可以使用任一框架构建更小、更可重用的部分。