Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在一个甜蜜的警报中呈现 angularjs 代码,例如
$scope.someVar = 'test'; swal("Title", "{ someVar }", "success")
我怎样才能做到这一点?
您不需要将 someVar 括在括号中,但您确实需要通过 $scope.someVar 调用它(我们在 javascript 中!)。所以一个例子是:
sweetAlert({ title: $scope.someTitle, text: $scope.someVar, }
请查看$interpolate 服务
检查示例:
swal("Title", $interpolate("{{someVar}}")($scope), "success");