0

Okey, please be patience. I only know jquery and I heard that use AngularJS is something that I should try.

So, what I need to to is visit a page on my local host "../asp/fases/fases-controler.asp" parse the json that this page shows me ( that is something like this: { "fasekind": [ "AAA", "BBB", "CCC" ] } ) and then mount on client side a list like this:

<ul>
   <li><input type="checkbox" /> <label>AAA</label></li>
   <li><input type="checkbox" /> <label>BBB</label></li>
   <li><input type="checkbox" /> <label>CCC</label></li>
</ul>

I do need a help with this. I only know the jQuery way. I have seen so many tutorials but I don't get it. I receive always Uncaught ReferenceError: $http is not defined and other erros messages.

I don't want someone to do that for me, I just need to figure out how it works.

js controller that I try... it does not work at all.

var app = angular.module("app", []);

app.controller("AppCtrl", function ($http) {
    var app = this;
    $http.get("../asp/fases/fases-controler.asp")
        .success(function (data) {
            app.fases = data;
        })

})
4
  • Where is your js/contoller code? Commented Jan 8, 2014 at 20:30
  • var app = angular.module("app", []); app.controller("AppCtrl", function ($http) { var app = this; $http.get("../asp/fases/fases-controler.asp") .success(function (data) { app.fases = data; }) }) Commented Jan 8, 2014 at 20:33
  • @UderMoreira Please do not use comments to add additional code. Edit your question if needed. Anyway, going through the angular docs and following some official tutorials is a way to go. Commented Jan 8, 2014 at 22:19
  • I found an answer [here][1], it was missing the JSON parse. [1]: stackoverflow.com/questions/17917238/… Commented Jan 10, 2014 at 15:34

2 Answers 2

1

CONTROLLER

var app = angular.module("app", []);

app.controller("AppCtrl", function ($scope, $http) {

    $http.get("../asp/fases/fases-controler.asp")
        .success(function (data) {
            $scope.fases = data;
        });
});

HTML

<div class="grid-12-12" ng-app='currentApp' ng-controller='ACtrl'>
    <label>Fases <em class="formee-req">*</em>
    </label>
    <ul class="formee-list">
        <li ng-repeat="list in fases">
            <input name="checkbox-01" type="checkbox" />
            <label>{{list}}</label>
        </li>
    </ul>
</div>

JSFIDDLE

Sign up to request clarification or add additional context in comments.

11 Comments

Do you have the exact same controller and html I posted?
html little bit diferent: <div class="grid-12-12" ng-app='app' ng-controller='AppCtrl'> <label>Fases <em class="formee-req">*</em></label> <ul class="formee-list"> <li ng-repeat="list in fases"> <input name="checkbox-01" type="checkbox" /> <label>{{list}}</label> </li> </ul> </div>
Any luck yet? @UderMoreira
|
0

I found an answer here, it was missing the JSON parse I guess. This is what I did:

JSON

{
  "fasekind": [ 
              "AAA",
              "BBB",
              "CCC" 
              ]
}

CONTROLLER

function FetchCtrl($scope, $http) {
        $scope.url = 'fases/fases-controler.asp';

        $http.get($scope.url).success(function (data, status) {
            $scope.fasekind = data.fasekind;
        }).error(function (data, status) {
                $scope.response = 'Request failed';
            });
}

HTML

    <div class="grid-12-12" ng-controller='FetchCtrl'>
        <label>Fases <em class="formee-req">*</em>
        </label>
        <ul class="formee-list">
            <li ng-repeat="foo in fasekind">
                <input name="checkbox-01" type="checkbox" />
                <label>{{foo}}</label>
            </li>
        </ul>
    </div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.