Skip to main content
Tweeted twitter.com/#!/StackCodeReview/status/638674282571268096
deleted 28 characters in body; edited tags; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

MVC partial views and angular jsAngularJS modules

I am using MVC+Angular

 . In MVC, I created partial views for Searchsearch,Listing listing, etc I. I show them using:

    @Html.Partial("_Search")
    
    @Html.Partial("_Featured")
    
    @Html.Partial("_Listing")

Previously each partial view had an ng-app and ng-controller.

Now I combined them all into one ng-apppapp. I added ng-app to master page, and I just used the ng-controller in every partial view.

 <div ng-controller="Search" class="slide">
some ng-repeat goes here
</div>

Below is my angularAngular code:

angular.module("ProductListing", [])
.controller("Search", function ($scope,$templateCache, $http) {
    $(document).on("keyup", ".txtTempleSearch", function () {
        var searchTerm=$(this).val();
        $.get(configUrl + "SearchGrouped/" + searchTerm, function (data) {
            $scope.Results = JSON.parse(data)[0].result;
                $scope.$apply();
        });
    });
})
.controller('featured', function ($scope) {
    $.get(configUrl + 'Featured', function (data) {
        $scope.featuredTemples = data;
        $scope.$apply();
    });
})

Is this approach correct or is it better in terms of maintainability/performance/best practice to have a different ng-app for different partial views and use angular.bootstrap?

MVC partial views and angular js modules

I am using MVC+Angular

  In MVC, I created partial views for Search,Listing etc I show them using

    @Html.Partial("_Search")
    
    @Html.Partial("_Featured")
    
    @Html.Partial("_Listing")

Previously each partial view had an ng-app and ng-controller

Now I combined them all into one ng-appp. I added ng-app to master page, and I just used the ng-controller in every partial view.

 <div ng-controller="Search" class="slide">
some ng-repeat goes here
</div>

Below is my angular code

angular.module("ProductListing", [])
.controller("Search", function ($scope,$templateCache, $http) {
    $(document).on("keyup", ".txtTempleSearch", function () {
        var searchTerm=$(this).val();
        $.get(configUrl + "SearchGrouped/" + searchTerm, function (data) {
            $scope.Results = JSON.parse(data)[0].result;
                $scope.$apply();
        });
    });
})
.controller('featured', function ($scope) {
    $.get(configUrl + 'Featured', function (data) {
        $scope.featuredTemples = data;
        $scope.$apply();
    });
})

Is this approach correct or is it better in terms of maintainability/performance/best practice to have a different ng-app for different partial views and use angular.bootstrap?

MVC partial views and AngularJS modules

I am using MVC+Angular. In MVC, I created partial views for search, listing, etc. I show them using:

@Html.Partial("_Search")
    
@Html.Partial("_Featured")
    
@Html.Partial("_Listing")

Previously each partial view had an ng-app and ng-controller.

Now I combined them all into one ng-app. I added ng-app to master page, and I just used the ng-controller in every partial view.

 <div ng-controller="Search" class="slide">
some ng-repeat goes here
</div>

Angular code:

angular.module("ProductListing", [])
.controller("Search", function ($scope,$templateCache, $http) {
    $(document).on("keyup", ".txtTempleSearch", function () {
        var searchTerm=$(this).val();
        $.get(configUrl + "SearchGrouped/" + searchTerm, function (data) {
            $scope.Results = JSON.parse(data)[0].result;
                $scope.$apply();
        });
    });
})
.controller('featured', function ($scope) {
    $.get(configUrl + 'Featured', function (data) {
        $scope.featuredTemples = data;
        $scope.$apply();
    });
})

Is this approach correct or is it better in terms of maintainability/performance/best practice to have a different ng-app for different partial views and use angular.bootstrap?

edited body
Source Link
Heslacher
  • 50.5k
  • 5
  • 81
  • 175

I am using MVC+Angular

In MVC, iI created partial views for Search,Listing etc I show them using

    @Html.Partial("_Search")
    
    @Html.Partial("_Featured")
    
    @Html.Partial("_Listing")

Previously each partial view had an ng-app and ng-controller

Now I combined them all into one ng-appp. I added ng-app to master page, and iI just used the ng-controller in every partial view.

 <div ng-controller="Search" class="slide">
some ng-repeat goes here
</div>

Below is my angular code

angular.module("ProductListing", [])
.controller("Search", function ($scope,$templateCache, $http) {
    $(document).on("keyup", ".txtTempleSearch", function () {
        var searchTerm=$(this).val();
        $.get(configUrl + "SearchGrouped/" + searchTerm, function (data) {
            $scope.Results = JSON.parse(data)[0].result;
                $scope.$apply();
        });
    });
})
.controller('featured', function ($scope) {
    $.get(configUrl + 'Featured', function (data) {
        $scope.featuredTemples = data;
        $scope.$apply();
    });
})

Is this approach correct or is it better in terms of maintainability/performance/best practice to have a different ng-app for different partial views and use angular.bootstrap?

I am using MVC+Angular

In MVC, i created partial views for Search,Listing etc I show them using

    @Html.Partial("_Search")
    
    @Html.Partial("_Featured")
    
    @Html.Partial("_Listing")

Previously each partial view had an ng-app and ng-controller

Now I combined them all into one ng-appp. I added ng-app to master page, and i just used the ng-controller in every partial view.

 <div ng-controller="Search" class="slide">
some ng-repeat goes here
</div>

Below is my angular code

angular.module("ProductListing", [])
.controller("Search", function ($scope,$templateCache, $http) {
    $(document).on("keyup", ".txtTempleSearch", function () {
        var searchTerm=$(this).val();
        $.get(configUrl + "SearchGrouped/" + searchTerm, function (data) {
            $scope.Results = JSON.parse(data)[0].result;
                $scope.$apply();
        });
    });
})
.controller('featured', function ($scope) {
    $.get(configUrl + 'Featured', function (data) {
        $scope.featuredTemples = data;
        $scope.$apply();
    });
})

Is this approach correct or is it better in terms of maintainability/performance/best practice to have a different ng-app for different partial views and use angular.bootstrap?

I am using MVC+Angular

In MVC, I created partial views for Search,Listing etc I show them using

    @Html.Partial("_Search")
    
    @Html.Partial("_Featured")
    
    @Html.Partial("_Listing")

Previously each partial view had an ng-app and ng-controller

Now I combined them all into one ng-appp. I added ng-app to master page, and I just used the ng-controller in every partial view.

 <div ng-controller="Search" class="slide">
some ng-repeat goes here
</div>

Below is my angular code

angular.module("ProductListing", [])
.controller("Search", function ($scope,$templateCache, $http) {
    $(document).on("keyup", ".txtTempleSearch", function () {
        var searchTerm=$(this).val();
        $.get(configUrl + "SearchGrouped/" + searchTerm, function (data) {
            $scope.Results = JSON.parse(data)[0].result;
                $scope.$apply();
        });
    });
})
.controller('featured', function ($scope) {
    $.get(configUrl + 'Featured', function (data) {
        $scope.featuredTemples = data;
        $scope.$apply();
    });
})

Is this approach correct or is it better in terms of maintainability/performance/best practice to have a different ng-app for different partial views and use angular.bootstrap?

Source Link

MVC partial views and angular js modules

I am using MVC+Angular

In MVC, i created partial views for Search,Listing etc I show them using

    @Html.Partial("_Search")
    
    @Html.Partial("_Featured")
    
    @Html.Partial("_Listing")

Previously each partial view had an ng-app and ng-controller

Now I combined them all into one ng-appp. I added ng-app to master page, and i just used the ng-controller in every partial view.

 <div ng-controller="Search" class="slide">
some ng-repeat goes here
</div>

Below is my angular code

angular.module("ProductListing", [])
.controller("Search", function ($scope,$templateCache, $http) {
    $(document).on("keyup", ".txtTempleSearch", function () {
        var searchTerm=$(this).val();
        $.get(configUrl + "SearchGrouped/" + searchTerm, function (data) {
            $scope.Results = JSON.parse(data)[0].result;
                $scope.$apply();
        });
    });
})
.controller('featured', function ($scope) {
    $.get(configUrl + 'Featured', function (data) {
        $scope.featuredTemples = data;
        $scope.$apply();
    });
})

Is this approach correct or is it better in terms of maintainability/performance/best practice to have a different ng-app for different partial views and use angular.bootstrap?