angularjs

Angular: Render externalized strings containing scope variables in the controller

一曲冷凌霜 提交于 2021-01-28 02:22:52
问题 Is it possible to render externalized strings (passed from server in my case) in the controller? My use case : I'm using angular-toastr as an alert service, and I must pass message and title to the toastr object. The tricky part is when the strings contain scope variables, e.g: stringFromServer = "Something with {{someVariable}} went wrong" . I know in my HTTP callback about the someVariable but I want to render it to the string before passing it as a message to the alert service. Is this

$routeProvider not working with html5Mode

给你一囗甜甜゛ 提交于 2021-01-28 02:21:40
问题 I just start to learn angularJs, and was trying to configure the partial page with angular route service. It worked with the hash format, however,when I tried to get rid of hash, the routeProvider stopped working. JS app.config(function($routeProvider,$locationProvider){ $locationProvider.html5Mode(true); $routeProvider.when("/", { templateUrl: "/index.html" }). when("/about", { templateUrl: "/partials/about.html" }). when("/contact", { templateUrl: "/partials/contact.html" }). otherwise({

How to download the file from webapi in Internet Explorer using angular post?

雨燕双飞 提交于 2021-01-28 02:07:15
问题 I am using angularjs http post to download the file from the Web Api on the button click.My code works fine in Google Chrome and Firefox but it is not working in the Internet Explorer. Here's my code $scope.CallApi = function () { $http({ url: some url, dataType: 'json', method: 'POST', data: null, responseType: 'arraybuffer', }).success(function (responsedata, status, xhr) { var file = xhr('Content-Disposition'); console.log(file); var filename = file.substr(21, 7); $scope.value =

Angularjs how to get URL referrer?

给你一囗甜甜゛ 提交于 2021-01-28 01:40:28
问题 In AngularJS, I have a login controller that is redirected to by every single page in the app if the user arrives at the page and is not logged in. After the login sequence, I would like to redirect the user back to the page that they came from. What's the best way to do this? 回答1: You can use history.back() to let the user navigate to the page he was previously. This works in every case, except when the user navigates directly to the login page :) Another solution is to pass a search

AngularJs ng-pattern regex

五迷三道 提交于 2021-01-28 01:12:59
问题 I am struggling writing a Regex for angular ng-pattern to validate a form input field.An example of the possible inputs are below Valid input: @tag1,@tag2,@tag3 @tag1, @tag2, @tag3 @tag1 Invalid Input: @tag 1 @tag 1, @tag2, @tag -3 @ta g1, @t ag2 Basically it should allow comma and comma whitespace, but not allow whitespace in between tags. I have written a REGEX that matches all the invalid input, but when I use this in ng-pattern it does not do the correct validation. Regex Built: /((^, @|@

Disable auto fill of input tag in html? [duplicate]

好久不见. 提交于 2021-01-28 01:04:18
问题 This question already has answers here : How do you disable browser Autocomplete on web form field / input tag? (85 answers) Closed 1 year ago . I have a webpage taking a new user name & password as input. For scripting, I am using AngularJS. <div class="form-group"> <input ng-model="prc.userName" placeholder="User Name" type="text" class="form-control" autocomplete="nope" required autofocus /> </div> This input box always gets auto-filled, I don't want it to get auto-filled. Question

ng-pattern to allow alpha and certain special characters

二次信任 提交于 2021-01-28 00:10:33
问题 In form - name field I want to do a validation against Should allow only Alpha characters Allow space Allow certain special characters - _ \ / - . ’ I tried, ng-pattern="/^[a-z]+[_+\+/+-+.+’][a-z]*$/" Looks like I have missed out something as its not working! 回答1: Let's see: Should allow only Alpha characters => [a-zA-Z] Allow space => [ ] or \s Allow certain special characters - _ \ / - . ’ ' => [_\\\/.’'-] So, combining all that, the pattern will look like: ng-pattern="/^[a-zA-Z _\\\/.’'-]+

$routeProvider not working with html5Mode

喜欢而已 提交于 2021-01-27 22:43:13
问题 I just start to learn angularJs, and was trying to configure the partial page with angular route service. It worked with the hash format, however,when I tried to get rid of hash, the routeProvider stopped working. JS app.config(function($routeProvider,$locationProvider){ $locationProvider.html5Mode(true); $routeProvider.when("/", { templateUrl: "/index.html" }). when("/about", { templateUrl: "/partials/about.html" }). when("/contact", { templateUrl: "/partials/contact.html" }). otherwise({

Angular/C# CORS Issue

妖精的绣舞 提交于 2021-01-27 21:27:27
问题 I hosted my client on localhost:8080/ and server on localhost:44302/ I am trying to link to my backend, but I am getting CORS issue. Below is my Angular http request $http.post(url, data, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'POST, OPTIONS' } }).success(function (response) { // rest of the code }).error(function (err, status) { // rest of the code }); On the server side which is written in C#, I

Headless chrome: chrome not reachable

懵懂的女人 提交于 2021-01-27 21:10:24
问题 I am using Chrome headless to run the protractor test. It runs for a while but after that i get the following error. [15:36:30] E/launcher - chrome not reachable (Session info: headless chrome=59.0.3071.115) (Driver info: chromedriver=2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 5 milliseconds Build info: version: '3.4.0', revision: 'unknown', time: