我正在尝试将数据从$ scope.abc()传递给实际函数。
[功能]
function sweetAlertCtrl($scope, SweetAlert, $state) {
$scope.demo1 = function () {
SweetAlert.swal({
title: "Good job!",
text: "You clicked the button!",
type: "success"
},
function ($state) {
$state.go('pjt.detailed', {id: $scope.id}) // This is where the data from $scope is received.
});
}
}
[来自$ scope的数据]
$scope.demo1($scope.id);
如何将$ scope.id传递给demo1()函数? 我甚至把$州放在了正确的位置吗?我是新手,这真令人困惑:)
请告诉我应该做些什么。
提前非常感谢!!
答案 0 :(得分:2)
将$state
放入controller
/ service
/ factory
/等其他依赖项中,如下所示:
app.service('myService', function($scope, $state) {
// Now you can use $state in all your functions here
})
答案 1 :(得分:1)
将$ scope.id作为参数传递给函数$ scope.demo1:
$scope.demo1 = function (id) {
SweetAlert.swal({
title: "Good job!",
text: "You clicked the button!",
type: "success"
},
function ($state) {
$state.go('pjt.detailed', {id: id})
});
}