Задать вопрос
@stasdushkin

Видимость переменных angularjs, и акардион?

Люди добрые, подскажите пожалуйста, очень слаб в angularjs, да и в js вообщем. Но вот пришлось столкнуться. Вот код и розметка.

<!doctype html>
<html ng-app="test">
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
        <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-resource.js"></script>
        <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.js"></script>
        <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.3.3.js"></script>
        <script src="js/bootstrap.js" type="text/javascript"></script>
        <script src="js/skript.js" ></script>
        <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
        <link href="css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
    </head>
    <body ng-controller="AccordionDemoCtrl">




    <uib-accordion>
        <uib-accordion-group is-open="status.jopen">
            <uib-accordion-heading>
                SOLR <i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': status.jopen, 'glyphicon-chevron-right': !status.jopen}"></i>
            </uib-accordion-heading>

            <div class="row">
                <div class="col-md-6">
                    <p class="input-group">
                        <input type="text" class="form-control" uib-datepicker-popup ng-model="fromPublishDate" is-open="popup1.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button>
                        </span>
                        <input type="text" class="form-control" uib-datepicker-popup ng-model="toPublishDate" is-open="popup2.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="open2()"><i class="glyphicon glyphicon-calendar"></i></button>
                        </span>
                        <button ng-click="solr()" class="btn btn-default">Найти</button><br/>
                    </p>
                </div>

            </div>

        </uib-accordion-group>
        <uib-accordion-group is-open="status.open">
            <uib-accordion-heading>
                DB <i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': status.open, 'glyphicon-chevron-right': !status.open}"></i>
            </uib-accordion-heading>

            <div class="row">
                <div class="col-md-6">
                    <p class="input-group">
                        <input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="from" is-open="popup1.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button>
                        </span>
                        <input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="to" is-open="popup2.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="open2()"><i class="glyphicon glyphicon-calendar"></i></button>
                        </span>
                        <button ng-click="db()" class="btn btn-default">Найти</button><br/>
                    </p>
                </div>
            </div>
        </uib-accordion-group>
    </uib-accordion>


    <ol ng-repeat="i in j">
        <li>{{i}}</li>

    </ol>



</body>
</html>


angular.module('test', ['ngAnimate', 'ui.bootstrap', 'ngResource']);
angular.module('test').controller('AccordionDemoCtrl', function ($scope, $resource) {

    var Answer = $resource('/query-solr', {fromPublishDate: "@fromPublishDate", toPublishDate: "@toPublishDate"});
    var AnswerDb = $resource('/query-base', {from: "@from", to: "@to"}, {headers: {'something': 'anything'}});
    $scope.solr = function () {

        Answer.get({fromPublishDate: $scope.fromPublishDate , toPublishDate: $scope.toPublishDate}, function (answer) {
            $scope.answer = answer;
            $scope.j = JSON.parse($scope.answer.message);
        }, function (answer) {
            $scope.j = answer.data;
        });
    };

    $scope.db = function () {

        AnswerDb.get({from: $scope.from, to: $scope.to}, function (answer) {
            $scope.answer = answer;
        }, function (answer) {
            $scope.answer = answer.data;
        });
    };

    $scope.open1 = function () {
        $scope.popup1.opened = true;
    };

    $scope.open2 = function () {
        $scope.popup2.opened = true;
    };


    $scope.popup1 = {
        opened: false
    };

    $scope.popup2 = {
        opened: false
    };



});


Вопрос в том, что переменные fromPublishDate, и toPublishDate когда блоки input находяться внутри акардеона, не видны, тоесть может и видны но так не достаются $scope.fromPublishDate. Подкажите в чем дело, и как решить проблемку??
  • Вопрос задан
  • 272 просмотра
Подписаться 1 Оценить Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы