0

i have included angular service in my project but the problem is it neither gives an error

nor called i don't know where is problem where as the second object is called

here is code for controller

var CreateController = ['$scope','$http', function ($scope, $http) {
    $scope.model = {};
    $scope.mydata = 'ajs works';
    $http.get('/Testing/Index').success(function(data){
        $scope.model = data;

    });
}];

and here is my view where i manipulate the angular js

<div ng-controller="CreateController">
    <table class="ui-sortable-handle">
        <tr>
            <td>
                <input type="hidden" id="qid" value="{{model.Questions.AddQuestionID}}" />
            </td>
        </tr>
        <tr>
            <td>
                <input type="hidden" id="complevel" value="{{model.Questions.ComplexityLevel}}" />
                <input type="hidden" id="servcomplvl" value="{{model.servercomplevel}}" />
            </td>
        </tr>
        <tr>
            <td>
                <h3>Question: {{model.Questions.Question}}</h3>
            </td>
        </tr>
        <tr ng-repeat="item in model.Options">
            <td class="switch radius">
                <input id="{{item.Options}}" type="radio" name="selectedvalue" value="{{item.Options}}">
                <label for="{{item.Options}}"></label>{{item.Options}}
            </td>
        </tr>

    </table>
    {{mydata}}

{{mydata}} this object works where as model object does not work please suggest what to do

2
  • If you open the browser's develper tools, do you see any script errors or errors in network resources? Commented Jan 6, 2015 at 9:13
  • no i did not see any error there Commented Jan 6, 2015 at 9:23

1 Answer 1

2

It probably does give an error, but you didn't include a callback for it.

$http.get('/Testing/Index')
.success(function(data){
    $scope.model = data;
})
.error(function(data){
    console.log("error");
});
Sign up to request clarification or add additional context in comments.

4 Comments

where i return from server is this return View(vm);
If you setup a working example of the problem in plnkr.co it'll be easier to spot the problem for us.
i did there but there i don't have my server controller so in $http.get() what URl i have to pass
Maybe you should use JSFiddle instead. There you can use /echo/json and echo/html to simulate remote resources.

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.