Enabling HTML 5 Mode in AngularJS 1.2

I’m working on an app that needs to use HTML 5 mode. Due to the fact that I am migrating an existing site to use AngularJS 1.2, I cannot have ‘#’ tags in my URL. Currently, I have the following: angular.module(‘myApp’, [‘ngRoute’]). config([‘$routeProvider’, ‘$locationProvider’, function($routeProvider, $locationProvider) { $locationProvider.html5Mode(true); $routeProvider .when(“/home”, {templateUrl:’home.html’, controller:’homeController’}) // other routes […]

What do you do to your JavaScript code before deployment?

Do you have a step in your deployment process that minifies JS? Do you have any sort of preprocessor for your JavaScript that allows you to leave in comments and console.logs and then have them automatically stripped out? Is your JavaScript machine generated by GWT or Script#? Do you use ANT or another tool to […]

Uncaught IndexSizeError: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index

What is problem here? if ( window.getSelection() ) EditField = window.getSelection().getRangeAt(0); throws error: Uncaught IndexSizeError: Failed to execute ‘getRangeAt’ on ‘Selection’: 0 is not a valid index.

How inject $stateProvider in angular application?

I try to use angular-ui, and try to inject $stateProvider: html <!DOCTYPE html> <html> <head> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js”></script> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular-resource.min.js”></script> <script src=”http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js”></script> <script src=”test/appModule.js”></script> </head> <body> <div ng-app=”appModule”> <div ng-controller=”appController”> {{date}} </div> </div> </body> </html> js (test/appModule.js) var module = angular.module(“appModule”, [‘ui.router’]); module.controller(‘appController’, [‘$scope’, ‘$stateProvider’, function ($scope, $stateProvider) { $scope.date = new Date(); }]); stack trace […]

What does RegExp.$1 do

I have come across a piece of code in JScript: RegExp.$1 Does anybody know what it does? If I output it on its own, I get nothing not even an error. I can’t find any reference to it at http://www.w3schools.com/jsref/jsref_obj_regexp.asp There was a regex search just prior to this piece of code, which I suspect […]

javascript add prototype method to all functions?

Is there a way to add a method to all javascript functions without using the prototype library? something along the lines of : Function.prototype.methodName = function(){ return dowhateverto(this) }; this is what i tried so far but it didnt work. Perhaps it is a bad idea also if so could you please tell me why? […]

Stripe Payment: Getting Error as Customer cus_***** does not have a linked card with ID tok_*****

In testing mode when I create a new customer and tries for payment, i got this error. Customer cus_7Zz2BCnybIZLGw does not have a linked card with ID tok_17Kp8GAwLkQPB7OqrrM73VVI Im using card number : 4242424242424242 exp_month :12 exp_year 2016 The return response is, Array ( [charge_status] => [error_info] => Array ( [type] => invalid_request_error [message] => […]

jQuery selector to grab cells in the same column

Given a multirow, multicolumn table, how can I select all cells in the same column as any arbitrary cell (e.g. a cell that is clicked on). Something like: $(“td”).click(function(){ var columnNo = $(this).columnNo? $(this).closest(“table”).find(“tr td:eq(“+columnNo+”)”).css(“color”, “red”); }); I need to do this without naming the columns individually. E.g. it should work on simple generic table […]

jQuery .load() / .ajax() not executing javascript in returned HTML after appended

I’ve tried using .load() and $.ajax to get some HTML that needs to be appended to a container, but the Javascript within the returned HTML is not being executed when I append it to an element. Using .load(): $(‘#new_content’).load(url+’ #content > *’,function() { alert(‘returned’); }); I’ve also tried switching to a $.ajax call. I then […]

How to Consume Http Component efficiently in a service in angular 2 beta?

I’m trying to play with Angular 2-beta and I want to work with Http component. But there is a serious problem here: I read this and I know in Angular 2(Unlike Angular 1), Http component is not a service that returns a Promise. It returns something called Observable. We know that a Component is better […]