AngularJS add';s变量前后的自动空格
我试图理解为什么当我从index.html发送到控制器时,在变量前后都会出现空白 在my index.html中:AngularJS add';s变量前后的自动空格,angularjs,Angularjs,我试图理解为什么当我从index.html发送到控制器时,在变量前后都会出现空白 在my index.html中: <input class="form-control" id='photo' type="texte" placeholder="photo" name="photo" ng-model="modifphoto"> <input class="form-control" id='nom' type="texte"
<input class="form-control" id='photo' type="texte"
placeholder="photo" name="photo" ng-model="modifphoto">
<input class="form-control" id='nom' type="texte"
placeholder="nom" name="nom" ng-model="modifnom">
<input class="form-control" id='prenom' type="texte"
placeholder="prenom" name="prenom" ng-model="modifprenom">
<input class="boutonModif" id="connect" type="submit"
value="connexion">
如果我写“test”并发送,当我在controller.js中执行“modifprenom”的console.log时,我得到了“test”
同样的事情也发生在这里:
<label ng-repeat="level in niveau">
<input type="radio" name="selectedLevel[]" value="{{level}}"
ng-checked="selection.indexOf(level)>-1"
ng-click="choixNiveau(level)">{{level}}
</label>
{{level}}
My$scope.niveau:
执行console.log时(在“:”和变量之间没有空格)
你可以在这里看到空间:
很明显,在我的service.js和server.js上,这个函数用于在我的“游戏”中更改名字,所以我的新名字将是“Dylan”,而不是“Dylan”。
所以,当我试图从服务器在mongodb中执行请求时,由于空间的原因,我正在使用错误的名称执行请求
我什么都试过了。。。
-use.trim()
-使用。替换。。。
-更改浏览器
所以我不知道如何处理它,我真的需要帮助。在
:
和变量之间的空格-这就是console.log所做的
如果不需要空格,请使用+
运算符将字符串缝合在一起
$scope.test = "test";
$scope.click = function() {
console.log("Test :" + $scope.test);
}
plunker:您能通过plnkr或codepen分享一个显示问题的实例吗?