angularjs - getting an error " Uncaught SyntaxError: Unexpected token (" -


while creating factory function insert space if there change lowercase uppercase in input

    var app = angular.module("myapp",[]);         app.factory('insertspace',function()         {            return{               processstring: function(input)            {               var output = "";               for(var i=0;i<input.length;i++)               {                 if(i>0 && input[i] == input[i].touppercase())                 {                    output = output + " ";                      }                 output = output + input[i];               }               return output;             }            }         });          app.controller("myctrl",function($scope,insertspace)         {            $scope.convert = function(input)            {                 $scope.output = insertspace.processstring(input);            };         }); 

you're code seems correct! made snippet can check out. please check code in rest of project. code posted here ok.

var app = angular.module("myapp", []);  app.factory('insertspace', function() {    return {      processstring: function(input) {        var output = "";        (var = 0; < input.length; i++) {          if (i > 0 && input[i] == input[i].touppercase()) {            output = output + " ";          }          output = output + input[i];        }        return output;      }    }  });    app.controller("myctrl", function($scope, insertspace) {      $scope.sampleinput = "helloworld";      $scope.convert = function(input) {      $scope.output = insertspace.processstring(input);    };  });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>    <div ng-app="myapp" ng-controller="myctrl">    <input type="text" ng-model="sampleinput" />        <br />    <br />      <a href="" ng-click="convert(sampleinput)">convert</a>        <br />    <br />      <span ng-bind="output"></span>  </div>


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -