Search Posts

Category: razor

Multiple level loop of same entity using AngularJS ng-repeat-start and ng-repeat-end in HTML table tag

Lets assume that I have an entity called GrandPa which is passed to my razor view, its model is as below(ParentChiled). As u see Child property is the List of ParentChiled class, using that GrandPa entity has 2 inner Child list of ParentChiled type which I want to loop thru each child also and print there Name. Class ParentChiled { public string Name {get;set;} public List<ParentChiled> Child {get;set;} //list of current class } here what […]

Razor Multi Conditioning AngularJS Data Binding

In razor view, I have a table, inside one of <td> i need to check conditions and then if condition is true then do the appropriate operation and dispalay in <td>.also good to say that value to be evaluated in condition is angularjs data binding statment {{value}}, for example <td> if ({{value==aa}}) {{value/a}} else if({{value==bb}}) {{value*b}} else if({{value==cc}}) {{value%c}}</td> tnx for helps. Source: AngularJS

Input type = "submit" not working in custom-control

how to Input type = "submit" not working in custom-control for some reason my input type= “submit” is not working (it’s only working for the 1st time). I wrote the input in a custom-control. Will that be a problem? Help is much appreciated. Thanks. Here is my code. page.zoom = 4; page.btn_Click = function() { if (page.MobileNo) { $http.get(serviceBasePath + ‘/api/Map/GetDeviceLocation?MobileNo=’ + page.MobileNo).then(function(response) { var deviceindex = page.DeviceData.findIndex(x => x.DeviceId==; if (deviceindex == -1) […]

How to render sections in using razor MVC view

I have a basic web site which is mixing cshtml content (note this is not an MVC site just a website serving up cshtml files) and angularJs. Default.cshtml is in the root of the site which references the _SiteLayout.cshtml file _SiteLayout contains the following html and razor syntax <!DOCTYPE html> <html lang=”en” ng-app=”app”> <head> <meta charset=”utf-8″ /> <title>@Page.Title</title> @RenderSection(“Styles”, false) <meta name=”viewport” content=”width=device-width” /> </head> <body> <div ng-view> @RenderBody() </div> <script src=”~/Scripts/angular.js”></script> <script src=”~/Scripts/ng-route.js”></script> <script […]

Gets Data in Json Format From AngularJs Controller

I am having a hard time with AngularJs. It works accordingly in some cases for me and when I try to change the template of the project, it doesn’t work anymore. Here is the scenario – I have a controller in ASP.NET MVC that returns the list of products in Json format and finally I call this controller using AngularJs controller as follows: C#: public JsonResult GetProducts() { var result = (from c in db.Products […]

Passing session object to angularjs function in razor view MVC

I need to pass the session object to a function that I call in ng-init. something like this; ng-init=initUser( @((User)Session[“userSession”]) ) I just want to pass my “User” object to the initUser method declared in angularjs. Is there a way to do it ?. I have searched for a solution and all are suggested to call an action method in the controller inside the “initUser” method and fetch the session object from the server […]

Data cannot be retrieved – AngularJS

I’ve a scenario where I’m fetching data from c# and want to show it on my cshtml view. Now the problem is although my Angular file (EditSingleRecord.js) is retrieving the list . I can’t fetch it in my cshtml(EditSingleRecord.cshtml). /// <reference path=”C:UsersDeepakdocumentsvisual studio 2015ProjectsEBazarEBazarScripts/angular-resource.min.js” /> (function() { //Create a Module var app = angular.module(‘MyApp’, []); // Will use [‘ng-Route’] when we will implement routing //Create a Controller app.controller(‘MYController’, function($scope, $http) { // here $scope is […]

Angularjs fails with passing data from ASP.Net Razor view

Recently I had a situation, when the user typed in input textbox something like “{{ text :}}” and saved it. And this caused the Angular fail on some pages. So, if I pass data to my controller from Razor view like this @{ var test = “{{ test :}}”; } <html> <head> </head> <body ng-app=”TestApp” ng-controller=”TestCtrl” ng-init=”test = ‘@test’;”> </body> </html> I get following error$parse/syntax?p0=:&p1=is%20an%20unexpected%20token&p2=6&p3=test%20:&p4=: Syntax Error: Token ‘:’ is an unexpected token at […]

How can Asp Net Core serve html static pages?

I start recently an Asp .Net Core app. Later i want to integrating it with Angular, but first i want a mechanism that will ‘replace’ cshtml with html. If i change extension from cshtml to html i get this ‘InvalidOperationException: The view ‘Index’ was not found’. Also i tried in Startup app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: “default”, template: “{controller=Home}/{action=Index}/{id?}”); }); but also didn’t work. Optional is to integrating cshtml layout content with html pages, […]