Hi guys,
I have the following function in my controller:
this.getTodos = function () {
TodoService.getTodos().then(function (todos) {
$scope.Todos = todos;
},
function (error) {
// TODO: display the error pop up
console.log(error);
});};
The following jasmine tests work fine:
it("Reading todos...", inject(function ($q) {
var deferredRead = $q.defer();
spyOn(todoServiceMock,
"getTodos").and.returnValue(deferredRead.promise);
deferredRead.resolve([{ TodoId: 10, Description: "Test",
Completed: false },
{ TodoId: 11, Description: "Test", Completed: false }]);
todoController.getTodos();
scope.$apply();
expect(scope.Todos.length).toBe(2);
}));
it("Reading todos, error...", inject(function ($q) {
var deferredRead = $q.defer();
spyOn(todoServiceMock,
"getTodos").and.returnValue(deferredRead.promise);
deferredRead.reject("There are no todos available!");
todoController.getTodos();
scope.$apply();
expect(scope.Todos.length).toBe([]);
}));
However, the view does not populate the rows ...
The view has code like:
<tr class="animate" ng-repeat="Todo in Todos() | orderBy:'TodoId' | filter:
filterTodo">
<td class="col-sm-1">{{Todo.TodoId}}</td>
<td class="col-sm-3">{{Todo.Description}}</td>
<td class="col-sm-1">
<span class="glyphicon glyphicon-check"
ng-show="{{Todo.Completed}}==true"></span>
<span class="glyphicon glyphicon-unchecked"
ng-show="{{Todo.Completed}}==false"></span>
</td>
<td class="col-sm-2">
<a href="" ng-click="selectTodo(Todo)"><span
class="glyphicon glyphicon-edit"></span></a>
</td>
</tr>
There is no error message ...
Any suggestions please?
many thanks
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.