我想有条件地启用/禁用按钮上的工具提示。 我这样做是为了测试禁用状态:
<button type="button"
uib-tooltip="test" tooltip-is-open="false">
</button>
但工具提示显示。 如何禁用工具提示?
谢谢
答案 0 :(得分:26)
您可以使用tooltip-enable="flag"
其中flag
是根据您的业务逻辑在控制器中设置的布尔值
答案 1 :(得分:2)
这种情况与您所寻找的情况并不完全匹配,但我发现我需要使用tooltip-trigger =“none”和tooltip-is-open的组合。例如:
<form name="formName">
<input name="inputName" type="text" required uib-tooltip="Required*" tooltip-placement="left" tooltip-trigger="none" tooltip-is-open="formName.inputName.$touched && formName.inputName.$invalid" />
</form>
希望它会帮助别人。
答案 2 :(得分:1)
它有什么问题?它在文档中清楚地给出了一个例子。
您应该使用 Card card=new Card(cardno,expmon,expyer,cvv);
card.validateNumber();
card.validateCVC();
new Stripe().createToken(card,PUBLISHABLE_KEY,
new TokenCallback() {
public void onSuccess(Token token) {
// Send token to your own web service
}
public void onError(Exception error) {
Toast.makeText(MainActivity.this, error.getLocalizedMessage(),
Toast.LENGTH_LONG).show();
}
}
);
标志。
Class Androidpay extends FragmentActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
// You will need to use your live API key even while testing
public static final String PUBLISHABLE_KEY = "pk_test_zbtcr8iFQrLNU3zu1";
// Unique identifiers for asynchronous requests:
private static final int LOAD_MASKED_WALLET_REQUEST_CODE = 1000;
private static final int LOAD_FULL_WALLET_REQUEST_CODE = 1001;
private GoogleApiClient googleApiClient;
private SupportWalletFragment walletFragment;
public static final int mEnvironment = WalletConstants.ENVIRONMENT_TEST;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.androidpay);
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Wallet.API, new Wallet.WalletOptions.Builder()
.setEnvironment(WalletConstants.ENVIRONMENT_TEST)
.setTheme(WalletConstants.THEME_LIGHT)
.build())
.build();
Wallet.Payments.isReadyToPay(googleApiClient).setResultCallback(
new ResultCallback<BooleanResult>() {
@Override
public void onResult(@NonNull BooleanResult booleanResult) {
if (booleanResult.getStatus().isSuccess()) {
if (booleanResult.getValue()) {
showAndroidPay();
} else {
// Hide Android Pay buttons, show a message that Android Pay
// cannot be used yet, and display a traditional checkout button
}
} else {
// Error making isReadyToPay call
// Log.e(TAG, "isReadyToPay:" + booleanResult.getStatus());
}
}
});
}
public void showAndroidPay()
{
setContentView(R.layout.activity_main);
walletFragment =
(SupportWalletFragment) getSupportFragmentManager().findFragmentById(R.id.wallet_fragment);
MaskedWalletRequest maskedWalletRequest = MaskedWalletRequest.newBuilder()
// Request credit card tokenization with Stripe by specifying tokenization parameters:
.setPaymentMethodTokenizationParameters(PaymentMethodTokenizationParameters.newBuilder()
.setPaymentMethodTokenizationType(PaymentMethodTokenizationType.PAYMENT_GATEWAY)
.addParameter("gateway", "stripe")
.addParameter("stripe:publishableKey", PUBLISHABLE_KEY)
.addParameter("stripe:version", com.stripe.Stripe.VERSION)
.build())
// You want the shipping address:
.setShippingAddressRequired(true)
// Price set as a decimal:
.setEstimatedTotalPrice("20.00")
.setCurrencyCode("USD")
.build();
// Set the parameters:
WalletFragmentInitParams initParams = WalletFragmentInitParams.newBuilder()
.setMaskedWalletRequest(maskedWalletRequest)
.setMaskedWalletRequestCode(LOAD_MASKED_WALLET_REQUEST_CODE)
.build();
// Initialize the fragment:
walletFragment.initialize(initParams);
}
public void onStart() {
super.onStart();
googleApiClient.connect();
}
public void onStop() {
super.onStop();
googleApiClient.disconnect();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == LOAD_MASKED_WALLET_REQUEST_CODE) { // Unique, identifying constant
if (resultCode == Activity.RESULT_OK) {
MaskedWallet maskedWallet = data.getParcelableExtra(WalletConstants.EXTRA_MASKED_WALLET);
FullWalletRequest fullWalletRequest = FullWalletRequest.newBuilder()
.setCart(Cart.newBuilder()
.setCurrencyCode("USD")
.setTotalPrice("20.00")
.addLineItem(LineItem.newBuilder() // Identify item being purchased
.setCurrencyCode("USD")
.setQuantity("1")
.setDescription("Premium Llama Food")
.setTotalPrice("20.00")
.setUnitPrice("20.00")
.build())
.build())
.setGoogleTransactionId(maskedWallet.getGoogleTransactionId())
.build();
Wallet.Payments.loadFullWallet(googleApiClient, fullWalletRequest, LOAD_FULL_WALLET_REQUEST_CODE);
}
} else if (requestCode == LOAD_FULL_WALLET_REQUEST_CODE)
{
if (resultCode == Activity.RESULT_OK) {
FullWallet fullWallet = data.getParcelableExtra(WalletConstants.EXTRA_FULL_WALLET);
String tokenJSON = fullWallet.getPaymentMethodToken().getToken();
//A token will only be returned in production mode,
//i.e. WalletConstants.ENVIRONMENT_PRODUCTION
if (mEnvironment == WalletConstants.ENVIRONMENT_PRODUCTION)
{
com.stripe.model.Token token = com.stripe.model.Token.GSON.fromJson(
tokenJSON, com.stripe.model.Token.class);
// TODO: send token to your server
Toast.makeText(Androidpay.this,"ready to send token"+token.getId()+token.getAmount(),Toast.LENGTH_SHORT).show();
}
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {}
@Override
public void onConnected(Bundle bundle) {}
@Override
public void onConnectionSuspended(int i) {}
}
tooltip-is-open