如何在angularjs中调用方法
下面是我的翡翠档案如何在angularjs中调用方法,angularjs,pug,Angularjs,Pug,下面是我的翡翠档案 .criteria(ng-show="$index <= maxCriteriaShow") input#checkbox-1.checkbox-custom(name='checkbox-1', type='checkbox', checked='', ng-model='criteria.checked') label.checkbox-custom-label(for='checkbox-1') span(
.criteria(ng-show="$index <= maxCriteriaShow")
input#checkbox-1.checkbox-custom(name='checkbox-1',
type='checkbox',
checked='', ng-model='criteria.checked')
label.checkbox-custom-label(for='checkbox-1')
span(translate="{{Key}}")
.criteria(ng show=“$index这里有两种初始化视图模型值的方法
ng init
假设您的$scope
已经通过$scope.\u getKey=function(){…};
公开了\u getKey
方法,您可以这样做
div(ng-init="_getKey()")
或
从视图控制器内部调用
这假定您使用的是视图控制器
声明视图控制器
div(ng-controller="ViewController")
span(translate="{{key}}")
.controller( 'ViewController', function( $scope ){
_getKey = function(){
//do something
$scope.key = someValue;
}
//do more stuff to your controller
_getKey()
}
调用视图控制器
div(ng-controller="ViewController")
span(translate="{{key}}")
.controller( 'ViewController', function( $scope ){
_getKey = function(){
//do something
$scope.key = someValue;
}
//do more stuff to your controller
_getKey()
}
以下是初始化视图模型值的两种方法
ng init
假设您的$scope
已经通过$scope.\u getKey=function(){…};
公开了\u getKey
方法,您可以这样做
div(ng-init="_getKey()")
或
从视图控制器内部调用
这假定您使用的是视图控制器
声明视图控制器
div(ng-controller="ViewController")
span(translate="{{key}}")
.controller( 'ViewController', function( $scope ){
_getKey = function(){
//do something
$scope.key = someValue;
}
//do more stuff to your controller
_getKey()
}
调用视图控制器
div(ng-controller="ViewController")
span(translate="{{key}}")
.controller( 'ViewController', function( $scope ){
_getKey = function(){
//do something
$scope.key = someValue;
}
//do more stuff to your controller
_getKey()
}
请提供有关您的问题的更多信息。您试图实现什么?什么是\u getKey()
?请提供有关您的问题的更多信息。您试图实现什么?什么是\u getKey()
?