This is my link in mvc view and it is redirecting to details view by invoking function call. pls see below.
<a href="/Home/Details" class="label label-primary" ng-click="addTask(c)">View Details</a>
TasksController.js
var lines =[]
$scope.addTask= function(c)
{
lines.push(c);
return lines;
}
alert(lines);
the return value (lines) is becoming null always for some reason. I am unable to figure it out. What I am trying to achieve is ,
I am passing the details from one view to another view in angularjs app.
EDITED BELOW (latest)
I am getting totally crazy and unable to acccomplish this.
Index.cshtml
<a href="/Home/Details" class="label label-primary" ng-controller="TasksController" ng-model="c" ng-click="addTask(c)">View Details</a>
(c is my object which I am trying to pass it to the next page)
TaskController.js
app.controller("TasksController", ['$scope' ,'TasksService', function ($scope, TasksService) {
$scope.addTask = function (currObj) {
var promiseAddTsk = TasksService.addProduct(currObj);
$scope.products = promiseAddTsk[0].Name;
console.log($scope.products);
};
}]);
TasksService.js
var productList = [];
this.addProduct = function (newObj) {
productList.push(newObj);
return productList;
};
Details.cshtml
<div ng-app="TasksModule" ng-controller="TasksController">
<div>
{{products}}
<span ng-model="products">{{products}}</span>
</div>
I can see the "Name" in scope.Products but it doesn't get bind in details.cshtml.
addTaskfunction you will always get[]as suggested look at services