Challenges using onsen angular starter app to join my own controller and model



  • I am trying to use a starter app to build gotten from one of the playground here. But attaching my controller to it gives me errors

    ons.bootstrap()
      .controller('SplitterController', function() {
        this.load = function(page) {
          mySplitter.content.load(page)
            .then(function() {
              mySplitter.left.close();
            });
        };
      });
    

    My controller looks like this:

    var postUrl =  "http://www.egovtoday.com/wp-json/wp/v2/posts?" ;
    
    var url =  "https://www.egovtoday.com/api/get_category_index" ;
    
     var module = angular.module('my-app', ['onsen']);
    module.controller('AppController', function($scope, $http) {
    
         $http.get(url)
        .then(function(response) {
            alert('success');
            console.log(response);
            console.log(response.status);
            console.log(response.data.categories);
    
            //$scope.todo= response.status;
            //$scope.categories = response.data.categories;
        });
    $scope.loadcategorynews = function(passedScope){
        var category_id= passedScope;
        var categoryUrl = postUrl+"categories="+category_id;
        alert(categoryUrl);
    
        //alert("1"+categoryUrl);
         $http.get(categoryUrl)
        .then(function(response) {
            alert('categories');
            console.log(response);
            //$scope.categoryposts = response.data;
    
        
        });
     //passedScope.somePropertyOfTheScope = false;/
    }
    
    
     });
    
    
    
    

    After using relevant ng-app, and ng-repeat and ng-controllers, The view doesn’t render at all. What can I do please?
    Any hints will be well cherished. Thanks in advance



  • I think those variables at the top should be inside the controller.


Log in to reply