lundi 11 mai 2015

I am not able to display values on my html page, have stored value in service but it is not displayed on second html page

This is my First html page:

         <form name="createdomain" class="form-horizontal" role="form" ng-controller="domainController">
              <swt-tree tree-data="domain.domainName" on-select="statementSelected(branch, selected_branches)" tree-control="statementTree" label-provider="rulesLabelProvider" content-provider="rulesContentProvider" expand-level="-1"></swt-tree> 
    <!-- This is used for adding a new page as a block to existing page -->
            <button  type="submit" ng-click="addTree(createdomain.$valid)" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ux_page_button ui-state-hover ui-button-text ui-c ng-binding ng-scope" id="btnData">OK</button>
              <button type="submit" ng-click="cancel()" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ux_page_button ui-state-hover ui-button-text ui-c ng-binding ng-scope" id="btnData">Cancel</button>

This is my controller :

    controller('domainController', ['$scope', '$state', 'DomainNameService', function($scope, $state, DomainNameService) {  
        $scope.activeTab = 1;
        $scope.currentDomain = {};
        $scope.statements=[];
        var statementTree = {};
        $scope.statementTree = statementTree = {};

         $scope.domainNameChanged = function() {
                var domainName= $scope.domain.name;
                alert($scope.domain.name);
         }
         $scope.addTree = function(isValid) {
                if(isValid) {
                    //if($scope.isAdd) 
                    var stType = $scope.domain.name;
                $scope.currentDomain = $scope.getNewDomain(stType);
                $scope.statements.push($scope.currentDomain);
                $scope.statementTree.setNewInput($scope.statements);
                $scope.isAdd = false;
                DomainNameService.addDomain($scope.domain.name);
                alert($scope.domain.name);
                $scope.domain.domainName = DomainNameService.getDomainName();
                alert($scope.domain.domainName);

                    $state.go('DomainTree');
                }
            }

            $scope.getNewDomain = function(stType) {
                return {name: stType};  
            }
    }])

This is my service method:

app.factory('DomainNameService', function() {
    var domainValue=[];
    return{
    addDomain: function(domainName){
        domainValue.push(domainName);
    },
    getDomainName: function(){
        return domainValue;
    }
    }
})

This is my Second html page where I want to display the value added from first html page:

    <div id="ruleEditorContainer" class="ui-layout-container"
        ng-controller="domainController"
        style="height: 95%; width: auto; overflow: hidden;">
    <div class="tab-content">
                                <div class="tab-pane active" id="statements">
                                {{domain.domainName}} <!-- Here I want to display the value which i got from first page -->
                                    <swt-tree tree-data="domain.domainName"
                                        on-select="statementSelected(branch, selected_branches)"
                                        tree-control="statementTree"
                                        label-provider="rulesLabelProvider"
                                        content-provider="rulesContentProvider" expand-level="-1"></swt-tree> 
                                </div>
    <div class="tab-pane" id="dictionary">Dictionary will be
                                    shown here</div>
                            </div>

I have stored the value in service which I got from First html page and in controller also I am getting the values from service method but I am not able to display this value on Second html page. Please help me out to resolve this issue. I am really stuck. Please help.

Aucun commentaire:

Enregistrer un commentaire