0

Well, I have 2 HTML pages. Parent html page has some images and names for those images. Both the details are retrieved from rest WCF. Now I am stuck up with next part. i.e. When i click a particular image, i should get the details of that image in the sub page(next html page).I used ng-click and tried the controller. I am able to see the result in console's log. But not in html page.

app.controller("details", function($scope, $http, RESTService) {    
    $scope.details=[];
    $scope.get=function(HTId){
        console.log(HTId);
        var url="url" +HTId;
        $http.get(url).then(function(pl) {
            console.log(pl);
            $scope.details=pl.data;
            console.log($scope.details);
        });
    }
});

This is my controller. Any issues? Thanks in advance for the relevant solutions :) :)

Ed B
  • 849
  • 1
  • 7
  • 25
  • By 2 pages do you mean the main page and a template for controller? Or you mean two separate html pages? `$scope.details` can be displayed (if properly bound in markup only in same main page – Kirill Slatin May 06 '15 at 07:40
  • 2 separate html pages. 2 different controllers. – Android-Learner May 06 '15 at 07:45
  • Angular is designed to support single-page web applications. With two different html pages, each will have to use `ng-app` directive to bootstrap and they will be absolutely isolated. You should use a template instead. Templates can have different controllers inside one angular app – Kirill Slatin May 06 '15 at 07:48
  • Fine.. I'll have templates now... But let me know how can i succeed in retriving the data.I ll have 2 controllers by now. How can i pass the parameter to other controller and fetch th details? – Android-Learner May 06 '15 at 07:54
  • 1
    It depends. If you have ControllerB nested in ControllerA, then the scope is [inherited](https://github.com/angular/angular.js/wiki/Understanding-Scopes) and you can simply read `details` in nested controllerB (and `$watch` it for changes). If they are not nested you can subscribe controllerB to action in controllerA via a callback. Or for these purposes you can define a service (being always a singleton it can transport data between two controllers) – Kirill Slatin May 06 '15 at 08:01
  • 1
    hmm why am I straining myself? :) everything was described long ago. Just bother to search http://stackoverflow.com/q/20181323/4573999 – Kirill Slatin May 06 '15 at 08:02
  • Cool man, tat was easy to understand. Thanks for th time you took to answer my question... – Android-Learner May 06 '15 at 08:06

0 Answers0