国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

angular.js - How do angular directives assign values ??to controls?
曾經(jīng)蠟筆沒有小新
曾經(jīng)蠟筆沒有小新 2017-05-15 17:05:14
0
3
664

For example, I have a parameter in the main controller: $scope.datas

Then, I have a directive here that requests data on the accused controller and then wants to assign the value to the main controller's $scope.datas.
How to succeed?

For example, command:


app.directive('profitSearch', function () {

    return {

        restrict: 'AE',
        scope: {
            datas: "="
        },
        templateUrl: "/templates/profitSearch.jsp",
        controller: function ($scope, $http) {

        $http({
                    url: 'doSearch.req',
                    method: 'POST',
                    data: $scope.searchObject
                }).success(function (response, header, config, status) {

                    $scope.datas = response.content;

                }).error(function (response, header, config, status) {


                });

}

The command is applied directly on the page:

<profit-search></profit-search>

But this assignment is wrong:
$compile:nonassign

How to break it? Didn’t I use two-way binding above?

曾經(jīng)蠟筆沒有小新
曾經(jīng)蠟筆沒有小新

reply all(3)
曾經(jīng)蠟筆沒有小新

There is no value assigned when you use it in the command. Try changing it to this.

 scope: {
    datas: "=?"
 },

Or assign a value to the command

<profit-search datas="datas"></profit-search>

https://docs.angularjs.org/error/$compile/nonassign

僅有的幸福

Do you need to write instructions? Recklessly! Not only does it waste time by writing instructions randomly, the performance will not be better. Writing a request directly in the service should solve the problem.

Peter_Zhu
<profit-search datas='datas'></profit-search>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template