Showing posts with label href. Show all posts
Showing posts with label href. Show all posts

Tuesday, May 26, 2015

Passing data from one page to another in Angular js

This articles shows the same,how this can be done


I want to pass the string value on a click event

Passing from  test.html  to testing.html

Step 1 : Sending string

test.html

passing on ng-click event

<li class="col-sm-6 col-md-6 col-lg-6 "><a ng-click="passResults()"><i class="fa fa-arrow-circle-o-right"></i> Pass </a></li>


test.js

passResults method which uses location.href and the text that I want to pass,here I am passing text from a text box, ng-model of text box is searchText

$scope.passResults = function () {

                              location.href = siteURL + $scope.searchText;

                          }


Step 2 : Collecting string

testing.html

Nothing needs to be done in HTML

Testing.js

$scope.searchItem = location.hash.split("/")[3];//split index may vary, you will understand why I did this if you take a look at my $routeProvide

This gets me text which was search in the textbox

Step 3 : Make changes to Admin App

For passing string from one page to another page primaryNav is the keyword, NO OTHER WORD can be used


AdminApp.js


app.config(function ($routeProvider) {
        $routeProvider
            .when('/MyProject/SeeAll/:primaryNav', {
                templateUrl: '../../Style Library/Scripts/ABC/ABC/Admin/Templates/testing.html',
                controller: 'MyCtrl'
            })




Hope this helps !