ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2017 www.aspforums.com. All rights reserved.What is Dependency Injection and how to use Dependency Injection in Controller of AngularJs in ASP.Net<p>hello sir&nbsp;</p> <p>i am new in angular js and want to know about dependency injection</p> <p>any one tell me the esay way what is dependency and why it is so usefull&nbsp;</p> <p>like below example we create scop and http as a injector i think</p> <pre class="brush: js"> countryApp.controller(&#39;CountryCtrl&#39;, [&#39;$scope&#39;, &#39;$http&#39;, function (scope, http){ http.get(&#39;countries.json&#39;).success(function(data) { scope.countries = data; });</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/853957/What-is-Dependency-Injection-and-how-to-use-Dependency-Injection-in-Controller-of-AngularJs-in-ASPNet/http://www.aspforums.net/Threads/853957/What-is-Dependency-Injection-and-how-to-use-Dependency-Injection-in-Controller-of-AngularJs-in-ASPNet/Mon, 12 Jun 2017 02:20:33 GMTSave image path to Database using AngularJS in ASP.Net<p>====&gt;the webservice</p> <pre class="brush: csharp">[WebMethod] public string insert(string city,string country,string flag) { try { using(SqlConnection conn =new SqlConnection(clsMain.sqlconnstring)) { conn.Open(); SqlCommand cmd = new SqlCommand(&#34;spInsertUploadPicture&#34;, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue(&#34;@city&#34;, city); cmd.Parameters.AddWithValue(&#34;@country&#34;,country); cmd.Parameters.AddWithValue(&#34;@imgpath&#34;, string.Format(&#34;../imageUploads/{0}&#34;,flag)); cmd.ExecuteNonQuery(); return &#34;Record Uploaded Successfully&#34;; } } catch (Exception) { throw; } }</pre> <p>===&gt;&gt;&gt;&gt; the controller</p> <pre class="brush: js">.directive(&#34;fileInput&#34;,function($parse){ return { restrict: &#34;A&#34;, link: function (scope,elem,attrs) { elem.bind(&#34;change&#34;, function () { $parse(attrs.fileInput).assign(scope, elem[0].files); scope.$apply(); }); } } }) .controller(&#34;imageUploadPracticeController&#34;, function ($scope,$http,$timeout) { var vm = this; vm.loading = false; vm.msg = false; vm.error = false; // read(); vm.imageUpload = function (event) { var files = event.target.files;//filelist object var file = files[files.length - 1]; vm.file = file; var reader = new FileReader(); reader.onload = vm.imageIsLoaded; reader.readAsDataURL(file); } vm.imageIsLoaded = function (e) { $scope.$apply(function () { vm.step = e.target.result; }); } vm.btnUpload = function () { vm.loading = true; var request = $http({ url: &#39;../services/svImageUpload.asmx/insert&#39;, method: &#39;POST&#39;, data: { city: vm.City, country: vm.Country, flag: vm.file.name }, //transformRequest:angular.identity, headers: {&#39;content-type&#39;:undefined} }); request.then(function (response) { read(); vm.loading = false; vm.error = false; vm.hurray = response.data; vm.msg = true; }, function (error) { vm.error = true; vm.error = error.data; vm.loading = false; vm.msg = false; }); //console.log(vm.City + &#39; &#39; + vm.Country + &#39; &#39; + vm.file.name); } var read = function () { var request = $http(&#34;../services/svImageUpload.asmx/GetAllFiles&#34;) .then(function (response) { vm.imgUploads = response.data; }); } vm.closeSuccessMsg = function () { vm.loading = false; vm.msg = false; vm.error = false; $(&#34;#txtCity&#34;).val(&#39;&#39;); $(&#34;#txtCountry&#34;).val(&#39;&#39;); } vm.closeErrorMsg = function () { vm.loading = false; vm.msg = false; vm.error = false; $(&#34;#txtCity&#34;).val(&#39;&#39;); $(&#34;#txtCountry&#34;).val(&#39;&#39;); } });</pre>http://www.aspforums.net/Threads/401358/Save-image-path-to-Database-using-AngularJS-in-ASPNet/http://www.aspforums.net/Threads/401358/Save-image-path-to-Database-using-AngularJS-in-ASPNet/Fri, 26 May 2017 11:39:14 GMTPass multiple parameters from AngularJS to ASP.Net MVC controller<div class="edit-comment-hide"> <div class="comment-body markdown-body markdown-format js-comment-body"> <p>In my scenario I wanna pass two parameters (Array,string) to API controller POST method, How can I determine resource and setCode for passing two parameter?</p> </div> </div> <pre class="brush: js"> Resource: app.factory(&#34;EthnicCodeResource&#34;, [&#39;$resource&#39;, function ($resource) { return { Codes: $resource(&#39;api/Code/:collection&#39;, { collection: &#39;@collection&#39; }, { postCollection: { method: &#39;POST&#39;, isArray: true } }), Effects: $resource(&#39;api/Effects:reviewSetCode&#39;, { reviewSetCode: &#39;@reviewSetCode&#39; }, { setCode: { method: &#39;POST&#39;, isArray: true } }), HCodes: $resource(&#39;api/HCodes&#39;) } + + Save: EthnicCodeResource.Effects.setCode($rootScope.myData).$promise.then (function() { }); + API Controller: [HttpPost] public void Post(List reviewSetCode) { // + } + +In my scenario I wanna pass two parameters (Array,string)to API controller POST method, +like, [HttpPost] public void Post(List reviewSetCode, string act) { // + }. + </pre> <p>In my scenario I wanna pass two parameters (Array,string) to API controller POST method, How can I determine resource and setCode for passing two parameter?</p>http://www.aspforums.net/Threads/124654/Pass-multiple-parameters-from-AngularJS-to-ASPNet-MVC-controller/http://www.aspforums.net/Threads/124654/Pass-multiple-parameters-from-AngularJS-to-ASPNet-MVC-controller/Tue, 12 May 2015 03:53:08 GMTMerge Table Rows for same column value using AngularJS in ASP.Net<p>I want to display record on my html page like this.</p> <table> <tbody> <tr> <td width="399"> <p>Invoice No 1</p> </td> <td width="399"> <p>Product 1</p> </td> </tr> <tr> <td width="399"> <p>&nbsp;</p> </td> <td width="399"> <p>Product 2</p> </td> </tr> <tr> <td width="399"> <p>&nbsp;</p> </td> <td width="399"> <p>Product 3</p> </td> </tr> <tr> <td width="399"> <p>Invoice No 2</p> </td> <td width="399"> <p>Product 1</p> </td> </tr> <tr> <td width="399"> <p>Invoice No 3</p> </td> <td width="399"> <p>Product 1</p> </td> </tr> <tr> <td width="399"> <p>Invoice No 4</p> </td> <td width="399"> <p>Product 1</p> </td> </tr> <tr> <td width="399"> <p>&nbsp;</p> </td> <td width="399"> <p>Product 2</p> </td> </tr> <tr> <td width="399"> <p>&nbsp;</p> </td> <td width="399"> <p>Product 3</p> </td> </tr> </tbody> </table> <p>&nbsp;I have this information in a list here's my code</p> <p>&nbsp;</p> <pre class="brush: csharp">static void Main(string[] args) { List&lt;Program&gt; listdata = new List&lt;Program&gt;(); listdata.Add(new Program { InvoiceNo=001, Product=&#34;Product1&#34;}); listdata.Add(new Program { InvoiceNo = 001, Product = &#34;Product2&#34; }); listdata.Add(new Program { InvoiceNo = 001, Product = &#34;Product3&#34; }); listdata.Add(new Program { InvoiceNo = 001, Product = &#34;Product4&#34; }); listdata.Add(new Program { InvoiceNo = 001, Product = &#34;Product5&#34; }); listdata.Add(new Program { InvoiceNo = 002, Product = &#34;Product1&#34; }); listdata.Add(new Program { InvoiceNo = 003, Product = &#34;Product1&#34; }); listdata.Add(new Program { InvoiceNo = 004, Product = &#34;Product1&#34; }); listdata.Add(new Program { InvoiceNo = 004, Product = &#34;Product2&#34; }); listdata.Add(new Program { InvoiceNo = 004, Product = &#34;Product3&#34; }); foreach (var item in listdata) { Console.WriteLine(String.Format(&#34;Invoice No : {0} Product : {1}&#34;,item.InvoiceNo,item.Product)); } Console.ReadLine(); }</pre> <p>Had used foreach for example purpose,have to display data on a html page in ng-repeat in angular js am not able to arrange the required list in this format as displayed above.</p>http://www.aspforums.net/Threads/110395/Merge-Table-Rows-for-same-column-value-using-AngularJS-in-ASPNet/http://www.aspforums.net/Threads/110395/Merge-Table-Rows-for-same-column-value-using-AngularJS-in-ASPNet/Sun, 09 Apr 2017 02:08:19 GMTHow to Print a page or DIV using AngularJS<table style="height: 132px;" width="250"> <tbody> <tr> <td>Product</td> <td>Date</td> <td>Time</td> </tr> <tr> <td>juice</td> <td>2015-02-25</td> <td>14:00:00</td> </tr> <tr> <td>cheese</td> <td>2015-02-25</td> <td>07:00:00</td> </tr> <tr> <td>CHIPS</td> <td>2015-02-25</td> <td>16:00:00</td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </tbody> </table> <p>i have the above table that is displayed on a web page. i want to have a button that when its clicked it must call a function to print out just the table. how do i achieve this? do i have to send this data to a text file or something first? but i need to do it in angular js.</p> <p>i have a function that displays the above table as follows&nbsp;</p> <pre class="brush: js">function Report($http) { var self = this; self.$http = $http; self.GetReport = function () { var result = Ajax.Get(self.$http, { url: GetReportjson, success: function (data) { self.DisplayReport = data; } }).error(function () { alert(&#34; error!&#34;); }); } </pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/177845/How-to-Print-a-page-or-DIV-using-AngularJS/http://www.aspforums.net/Threads/177845/How-to-Print-a-page-or-DIV-using-AngularJS/Wed, 25 Feb 2015 02:09:22 GMTHow to pass parameters from Angularjs to code behind<p>How to pass parameters from Angularjs to code behind.</p> <p>here is code</p> <p>&nbsp;$scope.submit = function (item) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $http.post('Default.aspx/getstring',{data: item})<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .success(function (data) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(status.d);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; })<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .error(function (data) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $scope.status = status;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>i want to pass parameters 'item' to&nbsp;getstring() web method.</p> <p>can anyone help me and iam new to angularjs</p> <p>Thanks in advance</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p>http://www.aspforums.net/Threads/176472/How-to-pass-parameters-from-Angularjs-to-code-behind/http://www.aspforums.net/Threads/176472/How-to-pass-parameters-from-Angularjs-to-code-behind/Sun, 07 Feb 2016 23:51:11 GMTHow to implement Autocomplete TextBox using AngularJS in ASP.Net<p>Previously I was using jquery for autocomplete &nbsp;but it seems slow that angular js, I want to know how to use angular js .</p> <p>below my jquery code</p> <pre class="brush: js"> $(&#34;#HTL&#34;).autocomplete({ source: function (request, response) { var customer = new Array(); $.ajax({ url: &#34;/Home/expedia&#34;, data: &#34;{ &#39;Text&#39;: &#39;&#34; + request.term + &#34;&#39; }&#34;, dataType: &#34;json&#34;, type: &#34;POST&#34;, contentType: &#34;application/json; charset=utf-8&#34;, success: function (data) { console.log(&#39;auto&#39;); response($.map(data, function (item, id) { return { label: item.region, val: item.region } })) }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); } }); }, focus: function (event, ui) { // prevent autocomplete from updating the textbox event.preventDefault(); // manually update the textbox $(this).val(ui.item.label); $(&#39;#HTLID&#39;).val(ui.item.val); }, minLength: 2, select: function (event, ui) { $(&#39;#HTL&#39;).val(ui.item.label); $(&#39;#HTLID&#39;).val(ui.item.val); return false; } }).data(&#34;autocomplete&#34;)._renderItem = function (ul, item) { return $(&#34;&lt;li id=&#34; + item.val + &#34;&gt;&lt;/li&gt;&#34;) .data(&#34;item.autocomplete&#34;, item) .append(&#34;&lt;a&gt;&lt;p&gt;&#34; + item.label + &#34;&lt;/p&gt;&lt;/a&gt;&#34;).appendTo(ul); };</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/429261/How-to-implement-Autocomplete-TextBox-using-AngularJS-in-ASPNet/http://www.aspforums.net/Threads/429261/How-to-implement-Autocomplete-TextBox-using-AngularJS-in-ASPNet/Mon, 24 Nov 2014 03:10:38 GMTHow to hide parameters from url using AngularJS in ASP.Net<p>how to hide id in url&nbsp;in angular js&nbsp;</p> <p>like my url&nbsp;&nbsp;<a href="http://localhost:6790/#/sectionkeywords/1">http://localhost:6790/#/sectionkeywords/1</a></p> <p>and i need to hide 1 which is id of product selection&nbsp;</p> <p>so how to hide this id ?</p>http://www.aspforums.net/Threads/145747/How-to-hide-parameters-from-url-using-AngularJS-in-ASPNet/http://www.aspforums.net/Threads/145747/How-to-hide-parameters-from-url-using-AngularJS-in-ASPNet/Fri, 21 Jul 2017 02:34:27 GMTHow to download files using AngularJS in ASP.Net<p>guys pls can anyone show me how to download files or images using angularjs</p>http://www.aspforums.net/Threads/635681/How-to-download-files-using-AngularJS-in-ASPNet/http://www.aspforums.net/Threads/635681/How-to-download-files-using-AngularJS-in-ASPNet/Mon, 29 May 2017 02:55:23 GMTGet url path without querystring using AngularJS in ASP.Net<p>Hi,</p> <p>When try get url&nbsp;path (home.html or page.html) with</p> <p><strong>var url = $location.path();</strong></p> <p>on my current path in browser add this&nbsp;<strong>#/home.html</strong></p> <p>and url look this:&nbsp;<a href="http://localhost:12241/home.html#/home.html">http://localhost:12241/home.html#/home.html</a></p> <p>i want only&nbsp;<a href="http://localhost:12241/home.html#/home.html">http://localhost:12241/home.html</a></p> <p>What is this, how solve this?</p>http://www.aspforums.net/Threads/206684/Get-url-path-without-querystring-using-AngularJS-in-ASPNet/http://www.aspforums.net/Threads/206684/Get-url-path-without-querystring-using-AngularJS-in-ASPNet/Wed, 15 Jun 2016 06:35:19 GMTCreate tic tac toe game using AngularJS in ASP.Net<p>Hi can you help me how to create tic tac toe game in angularjs any reference</p>http://www.aspforums.net/Threads/776244/Create-tic-tac-toe-game-using-AngularJS-in-ASPNet/http://www.aspforums.net/Threads/776244/Create-tic-tac-toe-game-using-AngularJS-in-ASPNet/Mon, 22 May 2017 02:24:59 GMTCreate custom Directives in AngularJS in ASP.Net<p>custom directive examples</p>http://www.aspforums.net/Threads/760351/Create-custom-Directives-in-AngularJS-in-ASPNet/http://www.aspforums.net/Threads/760351/Create-custom-Directives-in-AngularJS-in-ASPNet/Tue, 18 Apr 2017 01:50:49 GMTAuthentication using AngularJS $routeProvider<p>how to do authentication using angularjs ,only using $routeProvider</p>http://www.aspforums.net/Threads/681466/Authentication-using-AngularJS-routeProvider/http://www.aspforums.net/Threads/681466/Authentication-using-AngularJS-routeProvider/Fri, 18 Sep 2015 03:46:46 GMTAdd (Write), Read, Remove (Delete) Cookies in AngularJS Example<p>i already can get a cookie as the following. i call this cookie in my module and pass it as a parameter.how do i change the code to get a cookie in angular?</p> <p>&nbsp;</p> <pre class="brush: js">$(document).ready(function () { Cookie(); }); function getCookie(cname) { var name = cname + &#34;=&#34;; var ca = document.cookie.split(&#39;;&#39;); for (var i = 0; i &lt; ca.length; i++) { var c = ca[i].trim(); if (c.indexOf(name) == 0) return c.substring(name.length, c.length); } return &#34;&#34;; } function Cookie() { var cookie = getCookie(&#39;Id&#39;); } function Module($http) { var self = this; self.$http = $http; self.CookieID = getCookie(&#39;Id&#39;); self.test=function(){ var params = { testId:self.CookieID } } }</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/185913/Add-Write-Read-Remove-Delete-Cookies-in-AngularJS-Example/http://www.aspforums.net/Threads/185913/Add-Write-Read-Remove-Delete-Cookies-in-AngularJS-Example/Wed, 29 Apr 2015 03:23:32 GMT