עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

עזרה בתכנית באנגולר

Featured Replies

פורסם

שלום,

הקוד הבא קולט מתיבת טקסט קלטים, אם הקלט הוא אלכס, הוא צובע את הרקע בצהוב, אחרת הוא צובע באדום. אני רוצה לעבוד עם יותר משם אחד ויותר מצבע שני צבעים. לשם כך עליי לשלב פונקציה (כפי שרשום בקוד). אבל אין לי מושג איך לקשר אותה לקוד שרשמתי. אני יודע שצריך להוסיף אותה לקונטרולר, אבל אין לי מושג. אני מדגיש שאני מתלמד.

 

!DOCTYPE html>
<html>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
  <body ng-app="">
    <label>Enter your name:</label>
    <input type = "text" data-ng-model = "name" placeholder = "Insert your name:" />
    <h1 data-ng-if="name" >Hello    
      <span data-ng-style ="{'background-color': calculateBackgroundColor(name)}"> {{name}}</span>  </h1>
    <div data-ng-bind = "name"> </div>
    <button data-ng-click ="name = 'Alex'"> Fill your name</button>
  </body>
</html>

 

 

להלן הפונקציה שאני רוצה להוסיף:

 

function calculateBackgroundColor(name) {
    switch(name) {
        case 'Alex':
            return 'red';
        default:
            return 'blue';
    }
}

 

 

 

תודה על העזרה,

חיים

 

 

נערך על-ידי haim.hdd

פורסם
  • מחבר

לא משנה. הצלחתי

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.