Android iOS and Angularjs call each other to resolve the issue of the first call to iOS delivery header failed

Source: Internet
Author: User

Tag: Load without name on () return try style class gets

1.angular Call client method placed in try Catch

try {
Js_invoke.showsharedialog (Angular.tojson (obj)); Here's how you can put the client
} catch (e) {
Console.log (' recommend share ', obj);
}

2. The client calls the angular method, noting that the method needs to be global for the normal call

Declaring the method in the home index.html

var goBack = function () {return false};

On the page of the specific call, use

GoBack = function () {

return true;

};

First of all, angular call the customer service side Getwebtitle method on each page to return the method that the client needs to display the caption (Getwebtitle is the method defined for Android iOS)

Defining methods

function Initpagetitle (title) {var records = {name:title}; Try Catch (e) {}} $scope. $on ('$ionicView. Enter', function () {   //  Enter the page and call this is the method of ionic       initpagetitle (" home "//  can be called before entering the page });

There is no problem in Android such calls, except for the first entry in iOS.

It is important to note that for the first time, since the page has not finished loading the method has been executed so that the title of iOS returned directly is empty, to solve the problem requires iOS to actively call Angualrjs after the page load is completed get to the title

Home add var iospagetitle = function () {};

Write Iospagetitle = function () {Initpagetitle ("home page") in the controller of the homepage;

This allows the active call to the angular method after the iOS load is complete to ensure that the caption is displayed

Android iOS and Angularjs call each other to resolve the issue of the first call to iOS delivery header failed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.