angularjs在我的指令中更改范围变量

angularjs在我的指令中更改范围变量,angularjs,angularjs-directive,Angularjs,Angularjs Directive,这是我用angularjs编写的简单指令。我的指令很简单,可以$http获取值并设置变量。运行此指令时,出现$digest错误。为什么?我使用Angularjs 1.2.13 我的代码: 指令'dbLabel',['$http','remoteconf',函数$http,remoteconf{ 返回{ 限制:“EA”, 要求:'ngModel', 替换:正确, 模板:“{valdb}}”, 链接:功能范围、元素、属性、ctrl{ var table=attrs.dbTable; var字段=a

这是我用angularjs编写的简单指令。我的指令很简单,可以$http获取值并设置变量。运行此指令时,出现$digest错误。为什么?我使用Angularjs 1.2.13

我的代码:

指令'dbLabel',['$http','remoteconf',函数$http,remoteconf{ 返回{ 限制:“EA”, 要求:'ngModel', 替换:正确, 模板:“{valdb}}”, 链接:功能范围、元素、属性、ctrl{ var table=attrs.dbTable; var字段=attrs.dbField; var-where=attrs.dbWhere; 作用域。$applyfunction{ $http{ 方法:“POST”, url:remoteconf.init.appApiEntryPoint+attrs.ngModulo+'/api/service.php?x=getdbval', 数据:{ xtable:表, xfield:field, xwhere:在哪里 } }.successfunctiondata、状态、标题、配置{ scope.valdb=data.status; }; }; } } }];
不要使用范围。$apply,angular已处于某个$$阶段。即使您的代码从未到达,$http也被不正确地使用。如何更正我的代码?抱歉,我是新手…你的代码中有很多错误,从简单的开始。观看并逐步添加内容。经常运行代码,并使用浏览器devtools检查js错误。看一看你的照片