0

Here i did upto binding values into autocomplete text but when i select the value why its not transfor that page please Guid me

  public class CoursesList
    {
        public int Id { get; set; }
        public Nullable<int> CourseId { get; set; }
        public string CourseName { get; set; }
        public string Countrolle { get; set; }
        public string Action { get; set; }
    }

Here i'm Using Joining concept for Joining two tables

 public IEnumerable<CoursesList> GetCourses()
        {
            var x = from n in db.Courses
                    join c_List in db.CourseDetails on n.CourseId equals c_List.CourseId
                    select new CoursesList
                    {
                        CourseId=n.CourseId,
                        CourseName=n.CourseName,
                        Countrolle=c_List.Countrolle,Action=c_List.Action
                    };
            return x.ToList();
        }

Auto.Cshtml

<div ng-controller="Helloctrls">

        <div ng-cloak="" angucomplete-alt id="ex1_dropdown" placeholder="Search countries" pause="100" selected-object="afterSelectedCountry" class="postit"
             local-data="Countries" search-fields="CourseName" title-field="CourseName" minlength="1" maximumlength="3" input-class="form-control form-control-small"
             match-class="highlight">

        </div>

        <div ng-repeat="BindService in SelectedCountry">
            @{
                var uri = Url.Action("{{BindService.Countrolle}}");

                uri = HttpUtility.UrlDecode(uri);

            }
            <a href="@uri"></a>

        </div>
       </div>

Angular.js

angular.module('MyApp', ['angucomplete-alt'])
        .controller('Helloctrls', ['$scope','$http',function ($scope,$http) {

            $scope.Countries = [];
            $scope.SelectedCountry = null;

            $scope.afterSelectedCountry = function (selected) {
                if (selected) {
                    $scope.SelectedCountry = selected.originalObject;
                }
            }

            //Populate data from database 
            $http({
                method: 'GET',
                url: '/Dynamic/Courses'
            }).then(function (data) {
                $scope.Countries = data.data;
            }, function () {
                alert('Error');
            })

        }])

1 Answer 1

0

You can try using $location service in angularJs, here is a sample code based on your code

$scope.afterSelectedCountry = function (selected) {
            if (selected) {
                $scope.SelectedCountry = selected.originalObject;
                $location.url('/someview');
            }
        }

or

if you want to redirect outside of the app, you can use standard javascript

$scope.afterSelectedCountry = function (selected) {
            if (selected) {
                $scope.SelectedCountry = selected.originalObject;
                window.location.href = someurl;
            }
        }

For more details, please take a look at Using $window or $location to Redirect in AngularJS

2
  • Can you please elaborate on what you mean by multiple urls? Update your question with more details with examples of multiple urls.
    – Vinod
    Commented Dec 8, 2016 at 14:44
  • will u come in teamviewr Commented Dec 8, 2016 at 14:49

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.