Search Posts

Category: model-view-controller

Error when trying to access partials of another controller from one controller in angularjs

I have two controllers named controller1 and controller2 with its corresponding partials partials1 and partials2. When a button is clicked in partials1, i need to display the ui modal of partials2.And partials2 is will be as below <div data-feature-result-window class=”query-window” ng-show=”ctrl.showFeatures”> <div class=”panel panel-default” style=”margin-bottom: 10px;”> <div class=”panel-heading”> <b>Selection Results</b>&nbsp; <span class=”badge”>{{ ctrl.data}}</span> <button class=”close” ng-click=”ctrl.showFeatures = false”>&times;</button> </div> <div class=”panel-body” style=”overflow-y: auto;max-height: 23vh; font-size: small;”> <div class=”text-right”> <button class=”btn btn-default”> <i class=”fa fa-external-link fa-lg” […]

Radio Button ng-model & value are not binding correctly

With the Radio Box, i want to show/hide div, so i am using ng-switch. However, when radio is checked ‘Yes’, i want to set value in Db as 1 & open a new text box to write details. and if check ‘No’, just send value 0. But i couldn’t make ng-model & value works together. & YES i am new to angular & it is develop on .NET MVC Code First. <label class=”col-sm-4 control-label no-padding-right” […]

AngularJS – client side MVC – Where to place "Model" in directory structure

As we know , AngularJS follows MVC pattern(more correctly MV*) . We usually create different directories for each layer . eg ., controller JS will be “controllers” and view will be normally in “html” directory . (controllers will work with service classes to get the data from server . We use to place service request JS in “services” folder) But , we usually don’t have separate directory for “Model” classes . Can someone provide a […]

MVC AngularJs Post [FromBody] receiving viewModel null

I have a TestsController that has a Post method receiving a TestViewModel and it works has expected, except when, in the form that is submitted, one specific input field is empty. If that input is empty, the Post([FromBody]) TestViewModel viewModel) gets the viewModel null. The cshtml that contains the form and the select that it’s bugging me The form as a “Selecionar Questões” that goes to the DB and brings the questions that has the […]

Why the data get truncate to 0 in my controller?

Im migrating an application so this code was already working. I have one angular function to create random avl input to test my api. $scope.createAvl = function () { console.log($scope.avl); // for debug $scope.avl.push({ ‘tracker_avl_id’: getRandomArbitrary(0, 1000000, 1), ‘car_id’: getRandomArbitrary(0, 10000, 1), ‘x_lat’: getRandomArbitrary(-69, -66, 0), ‘y_long’: getRandomArbitrary(8, 10, 0), ‘azimuth’: getRandomArbitrary(0, 359, 1), ‘event_time’: getRandomDate() }); }; As you can see the data is created and show properly on the page Then the Save […]

how to disable specific dats from angular datepicker

var post1 = $http({ method: “POST”, url: “/Home/GetunAvailableDates”, dataType: ‘json’, data: sub1, headers: { “Content-Type”: “application/json” } }); var a = []; post.then(function (d) { if (d) { for (var i = 0; i < d.data.length; i++) { a.push(d.data[i].valueOf(Text).Text) } } console.log(“success”); }, function (d) { $window.alert(“Oops!! Something went wrong!!!!.”); }); this.selectedDates = a; I’m currently working in mvc project. I’m using AngularJs datepicker for my booking page. I need to disable dates which booking […]

Cross-Domain Http.Post AngularJS to MVC 5 Controller with parameter

I have a problem with some $http.post Cross-Domain I’ll explain the problem to you. This is my controller public ActionResult Index() { InfoModel model = (InfoModel)Session[“InfoPDF”]; Session[“InfoPDF”] = model; if (Session[“InfoPDF”] == null) { return View(“Error”); } else { return new ViewAsPdf(“Index”, model); } } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Index(InfoModel model) { if (model == null) { return View(“Error”); } else { Session[“InfoPDF”] = model; return new ViewAsPdf(“Index”, model); } } The second ActionResult doesn’t redirect […]

AngularJS) TypeError : serviceName.functionName() is not a function

I wanna make “Go back when cancel btn clicked” function. This is view code <div ng-controller=”goodCtrl”> <button class=”btn” ng-click=”cancel()”>Cancel</button> </div> And this is Js code 1) controller function goodCtrl($scope, $log, goodService) $scope.cancel = function(){ $log.debug(“goodCtrl – cancel”); goodService.cancel($scope); }; 2) service function goodService($log, $state) var methods = { cancel: function($scope) { $log.debug(“goodService – cancel”); $state.go(‘goback’); } } 3) module angular .module(‘goodmodule’) .controller(‘goodCtrl’, goodCtrl) .service(‘goodService’, goodService) But I got this problem TypeError : serviceName.functionName() is not […]

How to I use http.post in angular js to retrieve the rows of my datatable that are checked?

Hi I have a datatable with id, name, etc. and have checkboxes added within the angular js e.g. vm.dtColumns = [ DTColumnBuilder.newColumn(null).withTitle(titleHtml).notSortable() .renderWith(function(data, type, full, meta) { vm.selected[full.ID] = false; return ‘<input type=”checkbox” class=”checkedtestids” ng-model=”showCase.selected[‘ + data.ID + ‘]” ng-click=”showCase.toggleOne(showCase.selected)”>’; }), I have checkboxes that can select all rows from the header or individually. I have also got a var that keeps the id and changes the boolean state from true to false depending on […]

Next Page »