我有这样的表格:http://jsfiddle.net/dfJeN/
如您所见,输入的名称值是静态设置的:
name="username"
Run Code Online (Sandbox Code Playgroud)
,表单验证工作正常(添加一些东西并删除输入中的所有文本,必须出现一个文本).
然后我尝试动态设置名称值:http://jsfiddle.net/jNWB8/
name="{input.name}"
Run Code Online (Sandbox Code Playgroud)
然后我将此应用于我的验证
login.{{input.name}}.$error.required
Run Code Online (Sandbox Code Playgroud)
(此模式将用于ng-repeat)但我的表单验证已被破坏.它在我的浏览器中被正确解释(如果我检查了我看到login.username.$ error.required的元素).
任何的想法 ?
编辑:在控制台中记录范围后,似乎是
{{input.name}}
Run Code Online (Sandbox Code Playgroud)
表达式不是插值的.我的表单为{{input.name}}属性,但没有用户名.
更新:从1.3.0-rc.3 name ="{{input.name}}"按预期工作.请参阅#1404
我使用嵌套时遇到Angularjs问题ng-include与$compile功能.这是错误:
Error: [$injector:unpr] Unknown provider: $rootElementProvider <- $rootElement <- $location <- $anchorScroll <- ngIncludeDirective
Run Code Online (Sandbox Code Playgroud)
我想,我必须$rootElementProvider在编译流程中注入某个地方,但我不知道如何.
这是我的问题的一个问题:http ://plnkr.co/edit/K8iayGXGLx5QwHNNiLZ1?p=preview
所有代码都是必需的,我不能使用指令和控制器,模板也需要像这样缓存.此外,如果有人也知道如何摆脱已经运行的$timeout服务,$digest我将非常感激.
我对AngularJS范围和位置有一些问题.这是一个例子:
function CreateAccountCtrl($scope, $http, $location) {
...
$http.post(url,$scope.form).
success(function(data){
$location.path('/'); // I need to transfert data to the location
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:我想将数据传输到/ controller,我想使用rootScope,但我不认为这是最好的方法.
任何的想法 ?
这是我的问题:当触发window.onload时,不会初始化css样式.
<div id="foo"></div>
Run Code Online (Sandbox Code Playgroud)
css文件
#foo {
height: 200px
}
Run Code Online (Sandbox Code Playgroud)
js文件
window.onload = function(){
console.log(document.getElementById('foo').style.height);
};
Run Code Online (Sandbox Code Playgroud)
控制台显示:""
样式必须在不同的文件中,如果使用样式属性(style ="height = 200px"),它的工作原理.