离子含量和离子尾有不同的适用范围$ [英] ion-content and ion-footer have different $scope
问题描述
我有我的离子含量内的两个输入栏,他们都重视他们的NG-模式。然后,我离子页脚里面我有一个NG点击,我调用一个函数,并通过两个NG-车型。
I have two input fields inside my ion-content and they both have an ng-model attached to them. Then inside my ion-footer I have an ng-click where I call a function and pass in the two ng-models.
这一切优秀的工作时,我有NG点击,但是当我将它移动到页脚我得到了一个未定义的两个参数我传递给函数。
This all worked fine when I had the ng-click inside the ion-content, but when I move it to the footer I get undefined for the two parameters I pass to the function.
那么,这是否意味着离子含量和离子尾有不同的适用范围$的?即使它们是在同一个文件,并具有相同的控制器??
So does this mean that ion-content and ion-footer have different $scope's? Even though they're in the same file and have the same controller??
推荐答案
我相信离子页脚
&安培; 离子含量
创建新的子范围是的 中典型inerherit 从目前的范围。下面离子code会给你更好的说明它的内部工作原理,在范围:真,
负责创建一个新的子范围
I believe ion-footer
& ion-content
creates new child scope which is Prototypically inerherit from current scope. Below ionic code will give you better illustration that how it works internally, the scope: true,
is responsible for creating a new child scope.
code
.directive('ionContent', [
'$parse',
'$timeout',
'$ionicScrollDelegate',
'$controller',
'$ionicBind',
function($parse, $timeout, $ionicScrollDelegate, $controller, $ionicBind) {
return {
restrict: 'E',
replace: true,
transclude: true,
require: '^?ionNavView',
scope: true, //<-- this creates a prototypically inerherited scope
template:
'<div class="scroll-content">' +
'<div class="scroll"></div>' +
'</div>',
您需要使用。
标注将解决您的问题。
You need to use .
annotation will fix your problem
例如:
如果您正在使用变量作为原始像
If you are using variable as primitive like
$scope.volume = 5
然后,你需要使用:
Then you need to use:
$scope.data = { 'volume' : 5}
这篇关于离子含量和离子尾有不同的适用范围$的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!